MCPcopy Index your code
hub / github.com/apache/freemarker / Include

Method Include

src/main/java/freemarker/core/Include.java:80–121  ·  view source on GitHub ↗

@param template the template that this Include is a part of. @param includedTemplateName the name of the template to be included. @param encodingExp the encoding to be used or null, if it is a default. @param parseExp whether the template should be parsed (or is raw text)

(Template template,
            Expression includedTemplateName,
            Expression encodingExp,
            Expression parseExp)

Source from the content-addressed store, hash-verified

78 * @param parseExp whether the template should be parsed (or is raw text)
79 */
80 Include(Template template,
81 Expression includedTemplateName,
82 Expression encodingExp,
83 Expression parseExp) throws ParseException
84 {
85 String templatePath1 = template.getName();
86 int lastSlash = templatePath1.lastIndexOf('/');
87 templatePath = lastSlash == -1 ? "" : templatePath1.substring(0, lastSlash + 1);
88 this.includedTemplateName = includedTemplateName;
89 if (encodingExp instanceof StringLiteral) {
90 encoding = encodingExp.toString();
91 encoding = encoding.substring(1, encoding.length() -1);
92 }
93 else {
94 this.encodingExp = encodingExp;
95 }
96 if(parseExp == null) {
97 parse = true;
98 }
99 else if(parseExp.isLiteral()) {
100 try {
101 if (parseExp instanceof StringLiteral) {
102 parse = StringUtil.getYesNo(parseExp.getStringValue(null));
103 }
104 else {
105 try {
106 parse = parseExp.isTrue(null);
107 }
108 catch(NonBooleanException e) {
109 throw new ParseException("Expected a boolean or string as the value of the parse attribute", parseExp);
110 }
111 }
112 }
113 catch(TemplateException e) {
114 // evaluation of literals must not throw a TemplateException
115 throw new UndeclaredThrowableException(e);
116 }
117 }
118 else {
119 this.parseExp = parseExp;
120 }
121 }
122
123 void accept(Environment env) throws TemplateException, IOException {
124 String templateNameString = includedTemplateName.getStringValue(env);

Callers

nothing calls this directly

Calls 7

getYesNoMethod · 0.95
substringMethod · 0.80
getNameMethod · 0.45
toStringMethod · 0.45
isLiteralMethod · 0.45
getStringValueMethod · 0.45
isTrueMethod · 0.45

Tested by

no test coverage detected