/** * Get any valid Velocity starting with a <code>$</code>. * * @param array the source to parse * @param currentIndex the current index in the <code>array</code> * @param velocityBlock the buffer where to append matched velocity block * @param context the parser context to put some informations * @return the index in the <code>array</code> after the matched block * @throws InvalidVelocityException not a valid velocity block */ public int getVar(char[] array, int currentIndex, StringBuffer velocityBlock, VelocityParserContext context) throws InvalidVelocityException { return getVar(array, currentIndex, null, velocityBlock, context); }
/** * Get any valid Velocity starting with a <code>$</code>. * * @param array the source to parse * @param currentIndex the current index in the <code>array</code> * @param velocityBlock the buffer where to append matched velocity block * @param context the parser context to put some informations * @return the index in the <code>array</code> after the matched block * @throws InvalidVelocityException not a valid velocity block */ public int getVar(char[] array, int currentIndex, StringBuffer velocityBlock, VelocityParserContext context) throws InvalidVelocityException { return getVar(array, currentIndex, null, velocityBlock, context); }
} else if (array[i] == '$') { try { i = getVar(array, i, null, context); continue; } catch (InvalidVelocityException e) {
@Override public int getVar(char[] array, int currentIndex, StringBuffer velocityBlock, VelocityParserContext context) throws InvalidVelocityException { StringBuffer varName = new StringBuffer(); int i = super.getVar(array, currentIndex, varName, null, context); if (velocityBlock != null) { if ("msg".equals(varName.toString())) { // Make sure translated messages are protected since it can contain html velocityBlock.append("{{html clean=\"false\"}}"); velocityBlock.append(array, currentIndex, i - currentIndex); velocityBlock.append("{{/html}}"); } else { velocityBlock.append(array, currentIndex, i - currentIndex); } } ((ExtendedVelocityParserContext) context).setVelocity(true); return i; } }
if (array[i] == '$') { try { i = getVar(array, i, null, context); break; } catch (InvalidVelocityException e) {
/** * Handle velocity variables. * * @param contentBuffer the final result buffer * @param array the source * @param currentIndex the current index in the source * @param context the velocity parser context * @param filterContext the filter context * @return the index after the variable * @throws InvalidVelocityException not velocity */ private int cleanVar(StringBuffer contentBuffer, char[] array, int currentIndex, VelocityParserContext context, FilterContext filterContext) throws InvalidVelocityException { StringBuffer varName = new StringBuffer(); int i = this.velocityParser.getVar(array, currentIndex, varName, null, context); if (varName.toString().equals(BINDING_NEWLINE)) { flushWhiteSpaces(contentBuffer, filterContext, true); contentBuffer.append("${nl}"); filterContext.removeWhiteSpaces = true; } else { flushWhiteSpaces(contentBuffer, filterContext, false); contentBuffer.append(array, currentIndex, i - currentIndex); } return i; }
} else if (array[i] == '$') { try { i = getVar(array, i, null, context); continue; } catch (InvalidVelocityException e) {
if (array[i] == '$') { try { i = getVar(array, i, null, context); break; } catch (InvalidVelocityException e) {