All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jknack.handlebars.helper.ext.AssignHelper Maven / Gradle / Ivy

The newest version!
/*
 * Handlebars.java: https://github.com/jknack/handlebars.java
 * Apache License Version 2.0 http://www.apache.org/licenses/LICENSE-2.0
 * Copyright (c) 2012 Edgar Espina
 */
package com.github.jknack.handlebars.helper.ext;

import java.io.IOException;

import com.github.jknack.handlebars.Helper;
import com.github.jknack.handlebars.Options;

/**
 * You can use the assign helper to create auxiliary variables. Example:
 *
 * 
 *  {{#assign "benefitsTitle"}} benefits.{{type}}.title {{/assign}}
 *  <span class="benefit-title"> {{i18n benefitsTitle}} </span>
 * 
* * @author https://github.com/Jarlakxen */ public class AssignHelper implements Helper { /** A singleton instance of this helper. */ public static final Helper INSTANCE = new AssignHelper(); /** The helper's name. */ public static final String NAME = "assign"; @Override public Object apply(final String variableName, final Options options) throws IOException { CharSequence finalValue = options.apply(options.fn); options.context.data(variableName, finalValue.toString().trim()); return null; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy