Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
/**
* @param date Some date.
*/
{template .showDate}
<span>{$date |myFormatDateFunction}</span>
{/template}
/**
* @param date Some date.
*/
{template .showDate}
<span>{myFormatDateFunction($date)}</span>
{/template}
/**
Время вида Дата: DD MMM YYYY
@param? cssClass
@param date
**/
{template .dateShort}
{if $date}
<span class="{css nowrap}{sp}{if $cssClass}{$cssClass|id}{/if}">
{let $dFormat}{msg desc="time"}DD MMM YYYY{/msg}{/let}
{dateTimeFormat($date,$dFormat)|id}
</span>
{else}-{/if}
{/template}
@Override
public JsExpr computeForJsSrc(List<JsExpr> args) {
JsExpr timestampArg = args.get(0);
JsExpr formatArg = args.get(1);
if (args.size() == 2) {
return new JsExpr("moment(" + timestampArg.getText()
+ ").format(" + formatArg.getText() + ")",
Integer.MAX_VALUE);
} else {
JsExpr deltaArg = args.get(2);
return new JsExpr("moment(" + timestampArg.getText() + "+("
+ deltaArg.getText() + ")\").format("
+ formatArg.getText() + ")", Integer.MAX_VALUE);
}
}
public class MyprojectPluginModule extends AbstractModule
{
@Override public void configure() {
Multibinder<SoyFunction> soyFunctionsSetBinder =
Multibinder.newSetBinder(binder(), SoyFunction.class);
soyFunctionsSetBinder.addBinding().to(DateTimeFormaterFunction.class);
//...
soyFunctionsSetBinder.addBinding().to(FormatNumberFunction.class);
soyFunctionsSetBinder.addBinding().to(SubstringFunction.class);
soyFunctionsSetBinder.addBinding().to(ToFixedFunction.class);
soyFunctionsSetBinder.addBinding().to(ReplaceRegularExpressionFunction.class);
soyFunctionsSetBinder.addBinding().to(RandomFloatFunction.class);
soyFunctionsSetBinder.addBinding().to(RandomIntFunction.class);
}
}
java -cp ./cl-templates/js/SoyToJsSrcCompiler.jar:./cl-templates/plugins/cl-t-plugin.jar com.google.template.soy.SoyToJsSrcCompiler --pluginModules closure.plugins.MyprojectPluginModule <еще параметры>
Closure Platform. Костыли для Google Closure Library