本文整理汇总了Java中com.github.jknack.handlebars.Options.param方法的典型用法代码示例。如果您正苦于以下问题:Java Options.param方法的具体用法?Java Options.param怎么用?Java Options.param使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.jknack.handlebars.Options
的用法示例。
在下文中一共展示了Options.param方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public CharSequence apply(Number context, Options options) throws IOException {
String dateFormatString;
try {
dateFormatString = options.param(0, defaultFormatString);
} catch (ClassCastException cce) { // phorce.
LOG.warn(String.format("Date format %s isn't subclass of String, using default: %s", options.param(0), defaultFormatString));
dateFormatString = defaultFormatString;
}
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatString);
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(context.longValue());
return simpleDateFormat.format(cal.getTime());
}
示例2: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public Object apply(Object firstParam, Options options) throws IOException {
if (options.params.length > 0) {
int index = options.param(0);
if (firstParam instanceof JsonArray) {
JsonArray array = (JsonArray) firstParam;
if (array.size() > index) {
return array.getValue(index);
}
}
}
return null;
}
示例3: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public CharSequence apply(Object param0, Options options) throws IOException {
if(param0 != null){
String operator = options.param(0);
Object param1 = options.param(1);
boolean rs = applyIf(param0, param1, operator);
Object[] toks = options.params;
int len = toks.length;
if(len >= 6){
int i = 2;
while (i < len) {
String logicOperator = String.valueOf(toks[i]);
Object p0 = toks[i+1];
String compareOperator = String.valueOf(toks[i+2]);
Object p1 = toks[i+3];
if(logicOperator.equals("&&")){
rs = rs && applyIf(p0, p1, compareOperator);
} else if(logicOperator.equals("||")){
rs = rs || applyIf(p0, p1, compareOperator);
}
i+=4;
}
}
if(rs){
return options.fn(this);
}
}
return options.inverse(this);
}
示例4: embeddingHelper
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
private Helper<String> embeddingHelper() {
return new Helper<String>() {
@Override
public CharSequence apply(String arg0, Options arg1) throws IOException {
String toReturn;
String id = UUID.randomUUID().toString();
int index = arg1.param(1);
if (arg1.param(0).toString().contains("image")) {
toReturn =
"<button 'type='button'"
+ "class='btn btn-primary'"
+ "data-toggle='modal' "
+ "data-target='#" + id + "'>"
+ " Screenshot " + ++index + ""
+ "</button>";
toReturn +=
"<div id='" + id + "'"
+ "class='modal fade'"
+ "tabindex='-1'"
+ "role='dialog'"
+ "aria-labelledby='myModalLabel'"
+ "aria-hidden='true'>"
+ " <div style='width:90%;height:90%;'"
+ " class='modal-dialog'>"
+ " <div class='modal-content'>"
+ " <div class='modal-body'>"
+ " <img "
+ " src='data:image/png;base64," + arg0 + "'"
+ " class='img-responsive'>"
+ " </div>"
+ " </div>"
+ " </div>"
+ "</div>";
} else {
toReturn = "<pre>" + arg0 + "</pre>";
}
return toReturn;
}
};
}
示例5: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public CharSequence apply(Object context, Options options) throws IOException {
Gender gender = parseGender(options);
Case nameCase = parseCase(options);
String format;
if (context instanceof String) {
format = (String) context;
} else {
format = options.param(0, "{F} {I} {O}");
}
StringBuilder sb = new StringBuilder();
int start = 0;
int pos = format.indexOf('{');
while (pos > -1 && (pos + 2) < format.length()) {
sb.append(format, start, pos);
String elementValue = format.substring(pos, pos + 3);
NamePart element = resolveElement(elementValue);
if (element == null) {
sb.append('{');
start++;
} else {
String fieldValue = options.hash(element.getAttributeName(), null);
if (fieldValue == null) {
fieldValue = options.get(element.getAttributeName(), "");
}
if ("capitalize".equals(parseTransformation(options))) {
fieldValue = capitalize(fieldValue);
}
sb.append(applyName(element, fieldValue, gender, nameCase));
start = pos + 3;
}
pos = format.indexOf('{', start);
}
sb.append(format.substring(start));
return sb.toString();
}
示例6: getTimeZone
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
protected DateTimeZone getTimeZone (Options options) {
final String timeZoneName = options.param(0, getDefaultTimeZone());
try {
return DateTimeZone.forID(timeZoneName);
} catch (Exception e) {
return die("date_short: invalid timezone: "+timeZoneName);
}
}
示例7: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public Object apply(T firstParam, Options options) throws IOException {
T secondParam = options.param(0);
LOGGER.info("compareTo: {} vs {}", firstParam, secondParam);
return firstParam.compareTo(secondParam) >= 0 ? options.fn() : options.inverse();
}
示例8: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public Object apply(T firstParam, Options options) throws IOException {
T secondParam = options.param(0);
return firstParam.compareTo(secondParam) > 0 ? options.fn() : options.inverse();
}
示例9: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public Object apply(T firstParam, Options options) throws IOException {
T secondParam = options.param(0);
return firstParam.compareTo(secondParam) < 0 ? options.fn() : options.inverse();
}
示例10: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public Object apply(T firstParam, Options options) throws IOException {
T secondParam = options.param(0);
return firstParam.compareTo(secondParam) <= 0 ? options.fn() : options.inverse();
}
示例11: apply
import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public Object apply(Number firstParam, Options options) throws IOException {
Number secondParam = options.param(0);
return firstParam.equals(secondParam) ? options.fn() : options.inverse();
}