(Environment env)
| 121 | } |
| 122 | |
| 123 | void accept(Environment env) throws TemplateException, IOException { |
| 124 | String templateNameString = includedTemplateName.getStringValue(env); |
| 125 | if( templateNameString == null ) { |
| 126 | String msg = "Error " + getStartLocation() |
| 127 | + "The expression " + includedTemplateName + " is undefined."; |
| 128 | throw new InvalidReferenceException(msg, env); |
| 129 | } |
| 130 | String enc = encoding; |
| 131 | if (encoding == null && encodingExp != null) { |
| 132 | enc = encodingExp.getStringValue(env); |
| 133 | } |
| 134 | |
| 135 | boolean parse = this.parse; |
| 136 | if (parseExp != null) { |
| 137 | TemplateModel tm = parseExp.getAsTemplateModel(env); |
| 138 | if(tm == null) { |
| 139 | if(env.isClassicCompatible()) { |
| 140 | parse = false; |
| 141 | } |
| 142 | else { |
| 143 | assertNonNull(tm, parseExp, env); |
| 144 | } |
| 145 | } |
| 146 | if (tm instanceof TemplateScalarModel) { |
| 147 | parse = getYesNo(EvaluationRules.getString((TemplateScalarModel)tm, parseExp, env)); |
| 148 | } |
| 149 | else { |
| 150 | parse = parseExp.isTrue(env); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | Template includedTemplate; |
| 155 | try { |
| 156 | templateNameString = TemplateCache.getFullTemplatePath(env, templatePath, templateNameString); |
| 157 | includedTemplate = env.getTemplateForInclusion(templateNameString, enc, parse); |
| 158 | } |
| 159 | catch (ParseException pe) { |
| 160 | String msg = "Error parsing included template " |
| 161 | + templateNameString + "\n" + pe.getMessage(); |
| 162 | throw new TemplateException(msg, pe, env); |
| 163 | } |
| 164 | catch (IOException ioe) { |
| 165 | String msg = "Error reading included file " |
| 166 | + templateNameString; |
| 167 | throw new TemplateException(msg, ioe, env); |
| 168 | } |
| 169 | env.include(includedTemplate); |
| 170 | } |
| 171 | |
| 172 | public String getCanonicalForm() { |
| 173 | StringBuilder buf = new StringBuilder("<#include "); |
nothing calls this directly
no test coverage detected