Changeset 909
- Timestamp:
- 2008-12-02 12:23:33 (4 years ago)
- Location:
- trunk/universe/kauri-template/src
- Files:
-
- 7 edited
-
main/java/org/kauriproject/template/DocumentBlock.java (modified) (3 diffs)
-
main/java/org/kauriproject/template/ExecutionContext.java (modified) (3 diffs)
-
main/java/org/kauriproject/template/ImportBlock.java (modified) (2 diffs)
-
main/java/org/kauriproject/template/IncludeBlock.java (modified) (3 diffs)
-
main/java/org/kauriproject/template/OutputBlock.java (modified) (1 diff)
-
test/resources/org/kauriproject/template/include.xml (modified) (1 diff)
-
test/resources/org/kauriproject/template/include_result.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/universe/kauri-template/src/main/java/org/kauriproject/template/DocumentBlock.java
r822 r909 71 71 if (!include) { 72 72 context.getMacroRegistry().putAll(getCompiledTemplate().getMacroRegistry()); 73 // TODO: always or conditional ? add to start or end of list ?74 context.getExtendList().addAll(0, getCompiledTemplate().getExtendList());75 73 } 76 74 if (!context.isInherited() && !include) { … … 78 76 } 79 77 78 // update init context 79 context.getInitList().addAll(0, getCompiledTemplate().getExtendList()); 80 80 81 return super.executeAndProceed(context, result); 81 82 } … … 104 105 105 106 if (!context.isInherited()) { 106 result.endDocument();107 result.endDocument(); 107 108 } 108 109 return super.executeAndProceed(context, result); -
trunk/universe/kauri-template/src/main/java/org/kauriproject/template/ExecutionContext.java
r841 r909 44 44 private Map<String, List<InheritanceBlock>> inheritanceChain; 45 45 private Stack<SuperBlock> superBlockStack; 46 private List<InitBlock> extendList;46 private Stack<List<InitBlock>> initStack; 47 47 48 48 private int inherited = 0; … … 66 66 this.inheritanceChain = new HashMap<String, List<InheritanceBlock>>(); 67 67 this.superBlockStack = new Stack<SuperBlock>(); 68 this.extendList = new ArrayList<InitBlock>(); 68 this.initStack = new Stack<List<InitBlock>>(); 69 saveInit(); 69 70 } 70 71 … … 154 155 return attributes; 155 156 } 156 157 public List<InitBlock> get ExtendList() {158 return extendList;157 158 public List<InitBlock> getInitList() { 159 return initStack.peek(); 159 160 } 160 161 162 public List<InitBlock> saveInit() { 163 List<InitBlock> list = new ArrayList<InitBlock>(); 164 return initStack.push(list); 165 } 166 167 public List<InitBlock> restoreInit() { 168 return initStack.pop(); 169 } 170 161 171 public void setExtending(boolean extending) { 162 172 this.extending = extending; -
trunk/universe/kauri-template/src/main/java/org/kauriproject/template/ImportBlock.java
r832 r909 104 104 } 105 105 106 // start new context106 // start new template and init context 107 107 context.getTemplateContext().saveContext(); 108 context.saveInit(); 108 109 109 110 return imported; … … 124 125 } 125 126 126 // restore context127 // restore template and init context 127 128 context.getTemplateContext().restoreContext(); 129 context.restoreInit(); 128 130 return super.executeAndProceed(context, result); 129 131 } -
trunk/universe/kauri-template/src/main/java/org/kauriproject/template/IncludeBlock.java
r832 r909 109 109 context.getMacroRegistry().putAll(included.getMacroRegistry()); 110 110 111 // start new init context 112 context.saveInit(); 113 111 114 return included; 112 115 } … … 122 125 super(templateBlock, locator); 123 126 } 124 127 125 128 @Override 126 129 public Step executeAndProceed(ExecutionContext context, TemplateResult result) throws SAXException { … … 128 131 context.setSilencing(false); 129 132 } 133 // restore init context 134 context.restoreInit(); 130 135 return super.executeAndProceed(context, result); 131 136 } -
trunk/universe/kauri-template/src/main/java/org/kauriproject/template/OutputBlock.java
r894 r909 91 91 result.startElement(el.getUri(), el.getLocalName(), el.getName(), atts); 92 92 93 if (root && context.get ExtendList().size() > 0) {93 if (root && context.getInitList().size() > 0) { 94 94 context.setExtending(true); 95 95 // execute the extend blocks before proceding to next 96 for (InitBlock extendBlock : context.get ExtendList()) {96 for (InitBlock extendBlock : context.getInitList()) { 97 97 context.getExecutor().execute(extendBlock.getStartStep(), extendBlock.getEndStep().getCompiledNext(), context, result); 98 98 } -
trunk/universe/kauri-template/src/test/resources/org/kauriproject/template/include.xml
r822 r909 16 16 <p>but now we also know ${new}</p> 17 17 <t:callMacro name="macro" /> 18 <t:include src="included2.xml" mode="silent" />18 <t:include src="included2.xml" mode="silent" /> 19 19 <p>after silent inclusion</p> 20 20 <p>we have ${x} here</p> 21 21 <t:callMacro name="m" /> 22 <t:include src="init_special.xml" /> 22 23 </root> -
trunk/universe/kauri-template/src/test/resources/org/kauriproject/template/include_result.xml
r822 r909 14 14 <p>we have ieks here</p> 15 15 <p>pee and ieks</p> 16 <root xmlns:t="http://kauriproject.org/template"> 17 <a>aa en ieks</a> 18 <b>bee en "ei en ieks"</b> 19 </root> 16 20 </root>
Note: See TracChangeset
for help on using the changeset viewer.