public class InlineRewriter extends DepthFirstAdapter
The following template:
> " + x.foo + " <<"?>
will render as if it had been written:
> " + x.foo + " <<"?>
The inline command is intended only to allow neater template authoring. As such there is a restriction that any data commands (ie, bare literal text) inside an inline command can consist only of whitespace characters. This limits the risk of accidentally modifying the template's output in an unexpected way when using the inline command. Literal text may still be rendered in an inlined section if it is part of a var command.
Data commands containing only whitespace are effectively removed by replacing them with noop commands. These can be removed (if needed) by a later optimization step but shouldn't cause any issues.
Constructor and Description |
---|
InlineRewriter() |
Modifier and Type | Method and Description |
---|---|
void |
caseAInlineCommand(AInlineCommand node)
Removes data commands within an inline command.
|
caseAAddExpression, caseAAltCommand, caseAAndExpression, caseAAutoescapeCommand, caseACallCommand, caseACommaExpression, caseACommentCommand, caseAContentTypeCommand, caseACsOpenPosition, caseADataCommand, caseADecimalExpression, caseADecNumberVariable, caseADefCommand, caseADescendVariable, caseADivideExpression, caseAEachCommand, caseAEqExpression, caseAEscapeCommand, caseAEvarCommand, caseAExistsExpression, caseAExpandVariable, caseAFunctionExpression, caseAGteExpression, caseAGtExpression, caseAHardIncludeCommand, caseAHardLincludeCommand, caseAHexExpression, caseAHexNumberVariable, caseAIfCommand, caseAIncludeCommand, caseALincludeCommand, caseALoopCommand, caseALoopIncCommand, caseALoopToCommand, caseALteExpression, caseALtExpression, caseALvarCommand, caseAModuloExpression, caseAMultipleCommand, caseAMultiplyExpression, caseANameCommand, caseANameVariable, caseANeExpression, caseANegativeExpression, caseANoopCommand, caseANoopExpression, caseANotExpression, caseANumericAddExpression, caseANumericEqExpression, caseANumericExpression, caseANumericNeExpression, caseAOrExpression, caseASequenceExpression, caseASetCommand, caseAStringExpression, caseASubtractExpression, caseAUvarCommand, caseAVarCommand, caseAVariableExpression, caseAWithCommand, caseStart, defaultIn, defaultOut, inAAddExpression, inAAltCommand, inAAndExpression, inAAutoescapeCommand, inACallCommand, inACommaExpression, inACommentCommand, inAContentTypeCommand, inACsOpenPosition, inADataCommand, inADecimalExpression, inADecNumberVariable, inADefCommand, inADescendVariable, inADivideExpression, inAEachCommand, inAEqExpression, inAEscapeCommand, inAEvarCommand, inAExistsExpression, inAExpandVariable, inAFunctionExpression, inAGteExpression, inAGtExpression, inAHardIncludeCommand, inAHardLincludeCommand, inAHexExpression, inAHexNumberVariable, inAIfCommand, inAIncludeCommand, inAInlineCommand, inALincludeCommand, inALoopCommand, inALoopIncCommand, inALoopToCommand, inALteExpression, inALtExpression, inALvarCommand, inAModuloExpression, inAMultipleCommand, inAMultiplyExpression, inANameCommand, inANameVariable, inANeExpression, inANegativeExpression, inANoopCommand, inANoopExpression, inANotExpression, inANumericAddExpression, inANumericEqExpression, inANumericExpression, inANumericNeExpression, inAOrExpression, inASequenceExpression, inASetCommand, inAStringExpression, inASubtractExpression, inAUvarCommand, inAVarCommand, inAVariableExpression, inAWithCommand, inStart, outAAddExpression, outAAltCommand, outAAndExpression, outAAutoescapeCommand, outACallCommand, outACommaExpression, outACommentCommand, outAContentTypeCommand, outACsOpenPosition, outADataCommand, outADecimalExpression, outADecNumberVariable, outADefCommand, outADescendVariable, outADivideExpression, outAEachCommand, outAEqExpression, outAEscapeCommand, outAEvarCommand, outAExistsExpression, outAExpandVariable, outAFunctionExpression, outAGteExpression, outAGtExpression, outAHardIncludeCommand, outAHardLincludeCommand, outAHexExpression, outAHexNumberVariable, outAIfCommand, outAIncludeCommand, outAInlineCommand, outALincludeCommand, outALoopCommand, outALoopIncCommand, outALoopToCommand, outALteExpression, outALtExpression, outALvarCommand, outAModuloExpression, outAMultipleCommand, outAMultiplyExpression, outANameCommand, outANameVariable, outANeExpression, outANegativeExpression, outANoopCommand, outANoopExpression, outANotExpression, outANumericAddExpression, outANumericEqExpression, outANumericExpression, outANumericNeExpression, outAOrExpression, outASequenceExpression, outASetCommand, outAStringExpression, outASubtractExpression, outAUvarCommand, outAVarCommand, outAVariableExpression, outAWithCommand, outStart
caseEOF, caseInvalidToken, caseTAlt, caseTAnd, caseTArgWhitespace, caseTAssignment, caseTAutoescape, caseTBang, caseTBracketClose, caseTBracketOpen, caseTCall, caseTComma, caseTCommandDelimiter, caseTComment, caseTCommentStart, caseTContentType, caseTCsClose, caseTCsOpen, caseTData, caseTDecNumber, caseTDef, caseTDollar, caseTDot, caseTEach, caseTElse, caseTElseIf, caseTEq, caseTEscape, caseTEvar, caseTGt, caseTGte, caseTHardDelimiter, caseTHash, caseTHexNumber, caseTIf, caseTInclude, caseTInline, caseTLinclude, caseTLoop, caseTLt, caseTLte, caseTLvar, caseTMinus, caseTName, caseTNe, caseTOr, caseTParenClose, caseTParenOpen, caseTPercent, caseTPlus, caseTQuestion, caseTSet, caseTSlash, caseTStar, caseTString, caseTUvar, caseTVar, caseTWith, caseTWord, defaultCase, getIn, getOut, setIn, setOut
public void caseAInlineCommand(AInlineCommand node)
caseAInlineCommand
in interface Analysis
caseAInlineCommand
in class DepthFirstAdapter
JSilverBadSyntaxException
- if any data commands within the inline block contain
non-whitespace text.Copyright © 2010–2018 Google. All rights reserved.