Package freemarker.template

Examples of freemarker.template.TemplateModel


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

        Template template = configuration.getTemplate(location, deduceLocale());
        TemplateModel model = createModel();
        // Give subclasses a chance to hook into preprocessing
        if (preTemplateProcess(template, model)) {
            try {
                // Process the template
                PortletActionContext.getRenderResponse().setContentType(pContentType);
View Full Code Here


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

        Template template = configuration.getTemplate(location, deduceLocale());
        TemplateModel model = createModel();
        // Give subclasses a chance to hook into preprocessing
        if (preTemplateProcess(template, model)) {
            try {
                // Process the template
                PortletActionContext.getRenderResponse().setContentType(pContentType);
View Full Code Here

    }


    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

            fullPath.getParentFile().mkdirs();
            final PrintWriter out = new PrintWriter(fullPath);

            final Map<String, Object> rootMap = populateRootMap(input, baseContext, packageName, className);

            final TemplateModel model = new SimpleHash(rootMap);

            template.process(model, out);
            out.close();
        } catch (TemplateException e) {
            throw new RuntimeException("Unable to run template " + templateName + " to: " + fullPath, e);
View Full Code Here

        getContext().put("date", new SimpleDate(new Date(), TemplateDateModel.DATETIME));       
       
    }
   
    protected Object internalPutInContext(String key, Object value) {
    TemplateModel model = null;
    try {
      model = getContext().get(key);
    }
    catch (TemplateModelException e) {
      throw new ExporterException("Could not get key " + key, e);
View Full Code Here

      getContext().put(key, value);
      return model;
    }
   
    protected Object internalRemoveFromContext(String key) {
      TemplateModel model = null;
    try {
      model = getContext().get(key);
    }
    catch (TemplateModelException e) {
      throw new ExporterException("Could not get key " + key, e);
View Full Code Here

        return unwrap(model, true);
    }
   
    private static Object unwrap(TemplateModel model, boolean permissive) throws TemplateModelException {
        Environment env = Environment.getCurrentEnvironment();
        TemplateModel nullModel = null;
        if(env != null) {
            ObjectWrapper wrapper = env.getObjectWrapper();
            if(wrapper != null) {
                nullModel = wrapper.wrap(null);
            }
View Full Code Here

    private BuiltInsForMultipleTypes() { }

    static abstract class AbstractCBI extends BuiltIn {
       
        TemplateModel _eval(Environment env) throws TemplateException {
            TemplateModel model = target.eval(env);
            if (model instanceof TemplateNumberModel) {
                return formatNumber(env, model);
            } else if (model instanceof TemplateBooleanModel) {
                return new SimpleScalar(((TemplateBooleanModel) model).getAsBoolean()
                        ? MiscUtil.C_TRUE : MiscUtil.C_FALSE);
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.