public Template render(String source) throws IOException, ParseException { Template template = Context.getContext().getTemplate(); if (template == null) { throw new IllegalArgumentException("display context template == null"); } return engine.parseTemplate(source); }
public Template render(String source) throws IOException, ParseException { Template template = Context.getContext().getTemplate(); if (template == null) { throw new IllegalArgumentException("display context template == null"); } return engine.parseTemplate(source); }
public Template render(byte[] source) throws IOException, ParseException { Template template = Context.getContext().getTemplate(); if (template == null) { throw new IllegalArgumentException("display context template == null"); } String encoding = template.getEncoding(); return render(encoding == null ? new String(source) : new String(source, encoding)); }
public Template render(byte[] source) throws IOException, ParseException { Template template = Context.getContext().getTemplate(); if (template == null) { throw new IllegalArgumentException("display context template == null"); } String encoding = template.getEncoding(); return render(encoding == null ? new String(source) : new String(source, encoding)); }
public Reader getReader() { if (reader == null) { Template template = Context.getContext().getTemplate(); if (template != null) { try { return template.openReader(); } catch (IOException e) { return null; } } } return reader; }
public void render(Context context, Listener listener) throws IOException, ParseException { if (!context.getTemplate().isMacro()) { listener.render(context); return; } doRender(context, listener); }
public void render(Context context, Listener listener) throws IOException, ParseException { if (context.getTemplate().isMacro()) { listener.render(context); return; } doRender(context, listener); }
public void render(Context context, Listener listener) throws IOException, ParseException { if (! context.getTemplate().isMacro()) { listener.render(context); return; } doRender(context, listener); }
String prefix = UrlUtils.removeSuffix(context.getTemplate().getName()); String suffix = "." + dumpCodec.getFormat(); file = new File(dumpDirectory, prefix + suffix);
public void render(Context context, Listener listener) throws IOException, ParseException { if (context.getTemplate().isMacro()) { listener.render(context); return; } doRender(context, listener); }
String prefix = UrlUtils.removeSuffix(context.getTemplate().getName()); String suffix = "." + dumpCodec.getFormat(); file = new File(dumpDirectory, prefix + suffix);
public Object get(String key) { if ("parent".equals(key)) { return Context.getContext().getParent(); } else if ("super".equals(key)) { Context parent = Context.getContext().getParent(); return parent == null ? null : parent.getTemplate(); } else if ("this".equals(key)) { return Context.getContext().getTemplate(); } else if ("engine".equals(key)) { return Context.getContext().getEngine(); } else if ("out".equals(key)) { return Context.getContext().getOut(); } else if ("level".equals(key)) { return Context.getContext().getLevel(); } else { Template template = Context.getContext().getTemplate(); if (template != null) { return template.getMacros().get(key); } return null; } }
public Object get(String key) { if ("parent".equals(key)) { return Context.getContext().getParent(); } else if ("super".equals(key)) { Context parent = Context.getContext().getParent(); return parent == null ? null : parent.getTemplate(); } else if ("this".equals(key)) { return Context.getContext().getTemplate(); } else if ("engine".equals(key)) { return Context.getContext().getEngine(); } else if ("out".equals(key)) { return Context.getContext().getOut(); } else if ("level".equals(key)) { return Context.getContext().getLevel(); } else { Template template = Context.getContext().getTemplate(); if (template != null) { return template.getMacros().get(key); } return null; } }
public Template include(String name, Locale locale, String encoding) throws IOException, ParseException { if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("include template name == null"); } String macro = null; int i = name.indexOf('#'); if (i > 0) { macro = name.substring(i + 1); name = name.substring(0, i); } Template template = Context.getContext().getTemplate(); if (template != null) { if (StringUtils.isEmpty(encoding)) { encoding = template.getEncoding(); } name = UrlUtils.relativeUrl(name, template.getName()); if (locale == null) { locale = template.getLocale(); } } Template include = engine.getTemplate(name, locale, encoding); if (StringUtils.isNotEmpty(macro)) { include = include.getMacros().get(macro); } if (template != null && template == include) { throw new IllegalStateException("The template " + template.getName() + " can not be recursive including the self template."); } return include; }
private Locale getLocale() { Template template = Context.getContext().getTemplate(); if (template != null && template.getLocale() != null) { return template.getLocale(); } Object locale = resolver.get("locale"); if (locale instanceof Locale) { return (Locale) locale; } if (locale instanceof String) { return LocaleUtils.getLocale((String) locale); } return null; }
public Template include(String name, Locale locale, String encoding) throws IOException, ParseException { if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("include template name == null"); } String macro = null; int i = name.indexOf('#'); if (i > 0) { macro = name.substring(i + 1); name = name.substring(0, i); } Template template = Context.getContext().getTemplate(); if (template != null) { if (StringUtils.isEmpty(encoding)) { encoding = template.getEncoding(); } name = UrlUtils.relativeUrl(name, template.getName()); if (locale == null) { locale = template.getLocale(); } } Template include = engine.getTemplate(name, locale, encoding); if (StringUtils.isNotEmpty(macro)) { include = include.getMacros().get(macro); } if (template != null && template == include) { throw new IllegalStateException("The template " + template.getName() + " can not be recursive including the self template."); } return include; }
private Locale getLocale() { Template template = Context.getContext().getTemplate(); if (template != null && template.getLocale() != null) { return template.getLocale(); } Object locale = resolver.get("locale"); if (locale instanceof Locale) { return (Locale) locale; } if (locale instanceof String) { return LocaleUtils.getLocale((String) locale); } return null; }
public Resource read(String name, Locale locale, String encoding) throws IOException { if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("display template name == null"); } Template template = Context.getContext().getTemplate(); if (template != null) { if (StringUtils.isEmpty(encoding)) { encoding = template.getEncoding(); } name = UrlUtils.relativeUrl(name, template.getName()); if (locale == null) { locale = template.getLocale(); } } return engine.getResource(name, locale, encoding); }
name = name.substring(0, i); Template template = Context.getContext().getTemplate(); if (template != null) { if (StringUtils.isEmpty(encoding)) {
public Resource read(String name, Locale locale, String encoding) throws IOException { if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("display template name == null"); } Template template = Context.getContext().getTemplate(); if (template != null) { if (StringUtils.isEmpty(encoding)) { encoding = template.getEncoding(); } name = UrlUtils.relativeUrl(name, template.getName()); if (locale == null) { locale = template.getLocale(); } } return engine.getResource(name, locale, encoding); }