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


Java Options.hash方法代码示例

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


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

示例1: parseGender

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
private Gender parseGender(Options options) {
    String gender = options.hash("gender");

    if ("resolve".equalsIgnoreCase(gender)) {
        String patronymic = options.hash(ATTR_PATRONYMIC, null);
        if (patronymic == null) {
            options.get(ATTR_PATRONYMIC, "");
        }
        return PETROVICH.gender(patronymic, Gender.Male);
    } else if ("MALE".equals(gender)) {
        return Gender.Male;
    } else if ("FEMALE".equals(gender)) {
        return Gender.Female;
    }
    return Gender.Both;
}
 
开发者ID:ukase,项目名称:handlebars-petrovich4j,代码行数:17,代码来源:PetrovichHelper.java

示例2: apply

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public CharSequence apply(final String path, final Options options)
        throws IOException {
    notEmpty(path, "found: '%s', expected 'template path'", path);
    String wrapperName = options.hash("wrapper", "anonymous");
    final JsWrapper wrapper = JsWrapper.wrapper(wrapperName);
    notNull(wrapper, "found '%s', expected: '%s'",
            wrapperName, StringUtils.join(JsWrapper.values(), ", ").toLowerCase());

    Handlebars handlebars = options.handlebars;
    String name = path;
    if (name.startsWith("/")) {
        name = name.substring(1);
    }
    if (wrapper == JsWrapper.AMD) {
        name += handlebars.getLoader().getSuffix();
    }
    Template template = handlebars.compile(path);
    String precompiled = template.toJavaScript();
    return new Handlebars.SafeString(wrapper.wrap(name, precompiled));
}
 
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:22,代码来源:HandlebarsPrecompileHelper.java

示例3: applyWithCurrentTemplate

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public CharSequence applyWithCurrentTemplate(final String path, final Options options) {
    notEmpty(path, "found: '%s', expected 'template path'", path);
    String wrapperName = options.hash("wrapper", "anonymous");
    final JsWrapper wrapper = JsWrapper.wrapper(wrapperName);
    notNull(wrapper, "found '%s', expected: '%s'",
            wrapperName, StringUtils.join(JsWrapper.values(), ", ").toLowerCase());

    Handlebars handlebars = options.handlebars;
    String name = StringUtils.substringBeforeLast(path,".");
    if (name.startsWith("/")) {
        name = name.substring(1);
    }
    if (wrapper == JsWrapper.AMD) {
        name += handlebars.getLoader().getSuffix();
    }
    Template template = options.fn;
    String precompiled = template.toJavaScript();
    return new Handlebars.SafeString(wrapper.wrap(name, precompiled));
}
 
开发者ID:gtenham,项目名称:magnolia-templating,代码行数:21,代码来源:HandlebarsPrecompileHelper.java

示例4: radioGroup

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
public CharSequence radioGroup(Object obj, String field, String values, Options options) {
	StringBuilder radios = new StringBuilder();
	String labelClass = options.hash("labelClass");

	String tmpl = "<label class=\"%s\"><input type=\"radio\" name=\"%s\" value=\"%s\"%s>%s</label>";

	for(String value : values.split(",")) {
		try {
			String checked = "";
			if(BeanUtils.getSimpleProperty(obj, field).equalsIgnoreCase(value)) {
				checked = " checked";
			}
			radios.append(String.format(tmpl, labelClass, field, value, checked, WordUtils.capitalize(value)));
		} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
			log.warn("Could not find property {} on object {}", field, obj);
		}
	}

	return new Handlebars.SafeString(radios);
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:21,代码来源:FormHelper.java

示例5: link

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
private CharSequence link(Image image, String type, Options options) {
	boolean modal = options.hash("lightbox", true);
	String figureClass = options.hash("figure-class");
	String imgTag = String.format("<img src=\"%s\" title=\"%s\"/>",
			imageUrl(image, type),
			image.getTitle() == null ? "" : image.getTitle());

	if(figureClass != null) {
		imgTag = String.format("<figure class=\"%s\">%s</figure>", figureClass, imgTag);
	}

	if(modal) {
		imgTag = String.format("<a href=\"%s\" title=\"%s\">%s</a>",
				imageUrl(image, "fullsize"), generateCaption(image), imgTag);
	}

	return new Handlebars.SafeString(imgTag);
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:19,代码来源:ImageHelper.java

示例6: apply

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
@Override
public CharSequence apply(String relativePath, Options options) throws IOException {
    if (relativePath == null) {
        throw new IllegalArgumentException("Relative path of a favicon image cannot be null.");

    }

    RequestLookup requestLookup = options.data(HbsRenderable.DATA_KEY_REQUEST_LOOKUP);
    StringBuilder buffer = new StringBuilder("<link rel=\"shortcut icon\" href=\"")
            .append(requestLookup.getPublicUri())
            .append('/')
            .append(relativePath);
    for (Object param : options.params) {
        buffer.append(param);
    }
    String type = options.hash("type");
    if (type != null) {
        buffer.append("\" type=\"").append(type);
    }
    buffer.append("\" />\n");

    addToPlaceholder(buffer.toString(), options);
    return "";
}
 
开发者ID:wso2-attic,项目名称:carbon-uuf,代码行数:25,代码来源:FaviconHelper.java

示例7: 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

示例8: parseCase

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
private Case parseCase(Options options) {
    String nameCase = options.hash("case");
    if (nameCase == null) {
        return null;
    }
    return Arrays.stream(Case.values()).
            filter(aCase -> aCase.name().equals(nameCase)).
            findFirst().orElse(null);
}
 
开发者ID:ukase,项目名称:handlebars-petrovich4j,代码行数:10,代码来源:PetrovichHelper.java

示例9: apply

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
public CharSequence apply(Object context, Options options) throws IOException {
    final InitElement templatingElement = createTemplatingElement();
    initContentElement(options, templatingElement);

    String dialog = options.hash("dialog");
    templatingElement.setDialog(dialog);

    return render(templatingElement);
}
 
开发者ID:magnoliales,项目名称:magnolia-handlebars,代码行数:10,代码来源:CmsInitTemplateHelper.java

示例10: apply

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
public CharSequence apply(Object context, Options options) throws IOException {

        Node node = ((ContentMap) context).getJCRNode();

        String workspace = null;
        String nodeIdentifier = null;
        String path = null;
        try {
            workspace = node.getSession().getWorkspace().getName();
            nodeIdentifier = node.getIdentifier();
            path = node.getPath();
        } catch (RepositoryException e) {
            LOGGER.error("Cannot read properties from the node", e);
        }

        final ComponentElement templatingElement = createTemplatingElement();

        templatingElement.setContent(node);
        templatingElement.setWorkspace(workspace);
        templatingElement.setNodeIdentifier(nodeIdentifier);
        templatingElement.setPath(path);

        String dialog = options.hash("dialog");
        Boolean editable = options.hash("editable");
        Map<String, Object> contextAttributes = options.hash("contextAttributes");

        templatingElement.setDialog(dialog);
        templatingElement.setContextAttributes(contextAttributes);
        templatingElement.setEditable(editable);

        return render(templatingElement);
    }
 
开发者ID:magnoliales,项目名称:magnolia-handlebars,代码行数:33,代码来源:CmsComponentTemplateHelper.java

示例11: initContentElement

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
protected void initContentElement(Options options, AbstractContentTemplatingElement component)  {
    // @todo The freemarker code ensured that options could be cast to the correct type - here I am just assuming
    ContentMap contentMap = options.hash(CONTENT_ATTRIBUTE);
    Node contentNode = contentMap != null ? contentMap.getJCRNode() : null;
    String workspace = options.hash(WORKSPACE_ATTRIBUTE);
    String nodeIdentifier = options.hash(UUID_ATTRIBUTE);
    String path = options.hash(PATH_ATTRIBUTE);

    component.setContent(contentNode);
    component.setWorkspace(workspace);
    component.setNodeIdentifier(nodeIdentifier);
    component.setPath(path);
}
 
开发者ID:magnoliales,项目名称:magnolia-handlebars,代码行数:14,代码来源:AbstractTemplateHelper.java

示例12: parseTransformation

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
private String parseTransformation(Options options) {
    return options.hash("transform");
}
 
开发者ID:ukase,项目名称:handlebars-petrovich4j,代码行数:4,代码来源:PetrovichHelper.java

示例13: apply

import com.github.jknack.handlebars.Options; //导入方法依赖的package包/类
public CharSequence apply(Object context, Options options) throws IOException {

        String name = options.hash("name");
        String availableComponents = options.hash("components");
        String dialog = options.hash("dialog");
        String type = options.hash("type");
        String label = options.hash("label");
        String description = options.hash("description");
        Boolean editable = options.hash("editable");
        Map<String, Object> contextAttributes = options.hash("contextAttributes");

        RenderingModel model = (RenderingModel) ((Map) context).get("model");
        AreaState areaState = createAreaState(name, model.getNode());
        Node node = areaState.getNode();

        String workspace = null;
        String nodeIdentifier = null;
        String path = null;
        try {
            workspace = node.getSession().getWorkspace().getName();
            nodeIdentifier = node.getIdentifier();
            path = node.getPath();
        } catch (RepositoryException e) {
            LOGGER.error("Cannot read properties from the node", e);
        }

        final AreaElement templatingElement = createTemplatingElement();

        templatingElement.setContent(node);
        templatingElement.setWorkspace(workspace);
        templatingElement.setNodeIdentifier(nodeIdentifier);
        templatingElement.setPath(path);
        templatingElement.setArea(areaState.getAreaDefinition());

        templatingElement.setName(name);
        templatingElement.setAvailableComponents(availableComponents);
        templatingElement.setDialog(dialog);
        templatingElement.setType(type);
        templatingElement.setLabel(label);
        templatingElement.setDescription(description);
        templatingElement.setEditable(editable);
        templatingElement.setContextAttributes(contextAttributes);

        return render(templatingElement);
    }
 
开发者ID:magnoliales,项目名称:magnolia-handlebars,代码行数:46,代码来源:CmsAreaTemplateHelper.java


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