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


Java Options.param方法代码示例

本文整理汇总了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());
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:18,代码来源:FormatTimestampHelper.java

示例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;
}
 
开发者ID:Knotx,项目名称:knotx-handlebars-extension,代码行数:14,代码来源:ElementHelper.java

示例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);			
}
 
开发者ID:rfxlab,项目名称:analytics-with-rfx,代码行数:33,代码来源:HandlebarsHelpers.java

示例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;
        }
    };
}
 
开发者ID:web-innovate,项目名称:bootstraped-multi-test-results-report,代码行数:41,代码来源:Helpers.java

示例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();
}
 
开发者ID:ukase,项目名称:handlebars-petrovich4j,代码行数:41,代码来源:PetrovichHelper.java

示例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);
    }
}
 
开发者ID:cobbzilla,项目名称:cobbzilla-utils,代码行数:9,代码来源:HandlebarsUtil.java

示例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();
}
 
开发者ID:Knotx,项目名称:knotx-handlebars-extension,代码行数:7,代码来源:GreaterEqualHelper.java

示例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();
}
 
开发者ID:Knotx,项目名称:knotx-handlebars-extension,代码行数:6,代码来源:GreaterThanHelper.java

示例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();
}
 
开发者ID:Knotx,项目名称:knotx-handlebars-extension,代码行数:6,代码来源:LessThanHelper.java

示例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();
}
 
开发者ID:Knotx,项目名称:knotx-handlebars-extension,代码行数:6,代码来源:LessEqualHelper.java

示例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();
}
 
开发者ID:Knotx,项目名称:knotx-handlebars-extension,代码行数:6,代码来源:EqualsHelper.java


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