当前位置: 首页>>代码示例>>Java>>正文


Java Template.Fragment方法代码示例

本文整理汇总了Java中com.samskivert.mustache.Template.Fragment方法的典型用法代码示例。如果您正苦于以下问题:Java Template.Fragment方法的具体用法?Java Template.Fragment怎么用?Java Template.Fragment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.samskivert.mustache.Template的用法示例。


在下文中一共展示了Template.Fragment方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
    String body = frag.execute();
    int split = body.indexOf('|');
    String expr;
    String format;
    if (split == -1) {
        expr = body.trim();
        format = DEFAULT_FORMAT;
    } else {
        expr = body.substring(0, split).trim();
        format = body.substring(split + 1).trim();
    }
    if(expr.length() == 0) {
        log.debug("date_format_lambda param date is empty!");
        return;
    }
    out.write(new SimpleDateFormat(format).format(new Date(Long.parseLong(expr))));
}
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:20,代码来源:FormatDateLambda.java

示例2: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
	Map<String, Object> map = (Map<String, Object>) frag.context();
	
	map.put("usuario", sessionService.getUsuarioActual());
	
	body = frag.execute();
	compiler.compile("{{>nav}}").execute(map, out);
}
 
开发者ID:arubioVK,项目名称:La-Apostada,代码行数:10,代码来源:NavAdvice.java

示例3: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
	Map<String, Object> map = (Map<String, Object>) frag.context();
	
	if (flashService.getSuccess() != null) {
		map.put("success", flashService.getSuccess());
		flashService.setSuccess(null);
	} else if (flashService.getError() != null) {
		map.put("error", flashService.getError());
		flashService.setError(null);
	}
	
	body = frag.execute();
	compiler.compile("{{>flash}}").execute(map, out);
}
 
开发者ID:arubioVK,项目名称:La-Apostada,代码行数:16,代码来源:FlashAdvice.java

示例4: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
    String expr = frag.execute();
    int questIndex = expr.indexOf('?');
    if (questIndex == -1) {
        log.warn("Illegal ternary_lambda expression: {}", expr);
        return;
    }
    String compareExpr = expr.substring(0, questIndex).trim();
    int elseIndex = expr.indexOf(':');
    String value;
    String elseValue;
    if (elseIndex == -1) {
        value = expr.substring(questIndex + 1);
        elseValue = "";
    } else {
        value = expr.substring(questIndex + 1, elseIndex);
        elseValue = expr.substring(elseIndex + 1);
    }
    int compareIndex = compareExpr.indexOf('=');
    String result;
    if (compareIndex == -1) {
        result = compareExpr.length() == 0 || compareExpr.equals("false") ? elseValue : value;
    } else {
        result = compareExpr.substring(0, compareIndex).equals(compareExpr.substring(compareIndex + 1)) ? value : elseValue;
    }
    out.write(result);
}
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:29,代码来源:TernaryLambda.java

示例5: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
    String text = frag.execute();
    int split = text.indexOf('|');
    if (split == -1) {
        log.warn("Illegal variable_lambda expression: {}", text);
        return;
    }
    //noinspection unchecked
    ((Map<String, Object>) frag.context()).put(text.substring(0, split), text.substring(split + 1));
}
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:12,代码来源:VariableLambda.java

示例6: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
    String body = frag.execute();
    if (body.equals(((Map) frag.context()).get(NavNameLambda.NAME))) {
        out.write(ACTIVE_CLASS_NAME);
    }
}
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:8,代码来源:NavActiveLambda.java

示例7: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
    //noinspection unchecked
    Map<String, Object> context = (Map<String, Object>) frag.context();
    context.put("__body__", frag.execute());
    compiler.compile("{{>" + layoutMapper.getLayout((String) context.get("__template_name__")) + "}}").execute(frag.context(), out);
}
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:8,代码来源:LayoutLambda.java

示例8: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
    //noinspection unchecked
    ((Map<String, Object>) frag.context()).put(getName(), frag.execute());
}
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:6,代码来源:ExposeLambda.java

示例9: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
    out.write(formatUrl(frag.execute()));
}
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:5,代码来源:ResUrlLambda.java

示例10: execute

import com.samskivert.mustache.Template; //导入方法依赖的package包/类
@Override
public void execute(Template.Fragment frag, Writer out) throws IOException {
    if (!dev) {
        frag.execute(out);
    }
}
 
开发者ID:adaikiss,项目名称:mustache-showcase,代码行数:7,代码来源:DevLambda.java


注:本文中的com.samskivert.mustache.Template.Fragment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。