Package freemarker.template

Examples of freemarker.template.TemplateModel


                buf = null;
            }
            else if ("tag".equals(qName)) {
                try {
                    Class tagClass = ClassUtil.forName(tagClassName);
                    TemplateModel impl;
                    if(Tag.class.isAssignableFrom(tagClass)) {
                        impl = new TagTransformModel(tagClass);
                    }
                    else {
                        impl = new SimpleTagDirectiveModel(tagClass);
View Full Code Here


        unlistedModels.put(key, model);
    }

    public TemplateModel get(String key) throws TemplateModelException {
        // Lookup in default scope
        TemplateModel model = super.get(key);

        if (model != null) {
            return model;
        }
View Full Code Here

            String base = ResourceUtil.getResourceBase(req);
            locationArg = base + "/" + locationArg;
        }

        Template template = configuration.getTemplate(locationArg, deduceLocale());
        TemplateModel model = createModel();

        // Give subclasses a chance to hook into preprocessing
        if (preTemplateProcess(template, model)) {
            try {
                // Process the template
View Full Code Here

        }
    }

    public static TemplateModel autoWrap(Object obj, Environment env) {
       BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
       TemplateModel templateModelObj = null;
       try {
           templateModelObj = wrapper.wrap(obj);
       } catch (TemplateModelException e) {
           throw new RuntimeException(e.getMessage());
       }
View Full Code Here

     */
    @Test
    public void testRemoveValue() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
        expect(model.get("key")).andReturn(null);
View Full Code Here

     */
    @Test
    public void testGetKeys() {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        Set<String> names = new HashSet<String>();
        names.add("testGetKeys");
       
        Writer writer = new StringWriter();
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test(expected = FreemarkerRequestException.class)
    public void testGetKeysException() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModelEx model = createMock(TemplateHashModelEx.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        Set<String> names = createMock(Set.class);
        Iterator<String> namesIt = createMock(Iterator.class);
        Writer writer = new StringWriter();
View Full Code Here

     */
    @Test
    public void testSetValue() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
View Full Code Here

     */
    @Test(expected = FreemarkerRequestException.class)
    public void testSetValueException() throws TemplateModelException {
        Template template = createMock(Template.class);
        TemplateHashModel model = createMock(TemplateHashModel.class);
        TemplateModel valueModel = createMock(TemplateModel.class);
        Configuration configuration = createMock(Configuration.class);
        ObjectWrapper objectWrapper = createMock(ObjectWrapper.class);
        Writer writer = new StringWriter();

        expect(template.getMacros()).andReturn(new HashMap<Object, Object>());
View Full Code Here

    }

    @Override
    public Object getValue(String key) {
        try {
            TemplateModel variable = request.getVariable(key);
            if (variable != null) {
                return DeepUnwrap.unwrap(variable);
            }
            return null;
        } catch (TemplateModelException e) {
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.