module Zafu
module Experimental
# part caching
def r_cache
kpath = @params[:kpath] || Page.kpath
out "<% #{cache} = Cache.with(visitor.id, visitor.group_ids, #{kpath.inspect}, #{helper.send(:lang).inspect}, #{template_url.inspect}) do capture do %>"
out expand_with
out "<% end; end %><%= #{cache} %>"
end
def cache
return @cache if @cache
if @context[:cache] =~ /^cache(\d+)$/
@cache = "cache#{$1.to_i + 1}"
else
@cache = "cache1"
end
end
def r_flash_messages
type = @params[:show] || 'both'
"
" +
if (type == 'notice' || type == 'both')
"<% if flash[:notice] -%>
<%= flash[:notice] %>
<% end -%>"
else
''
end +
if (type == 'error' || type == 'both')
"<% if flash[:error] -%>
<%= flash[:error] %>
<% end -%>"
else
''
end +
"
"
end
# Prepare stylesheet and xml content for xsl-fo post-processor
def r_fop
return parser_error("missing 'stylesheet' argument") unless @params[:stylesheet]
# get stylesheet text
xsl_content, absolute_url, doc = self.class.get_template_text(@params[:stylesheet], @options[:helper], @options[:current_dir])
return parser_error("stylesheet #{@params[:stylesheet].inspect} not found") unless doc
template_url = (self.template_url.split('/')[0..-2] + ['_main.xsl']).join('/')
helper.save_erb_to_url(xsl_content, template_url)
out "\n"
out "\n" if doc
out expand_with
end
# Prepare content for LateX post-processor
def r_latex
out "% latex\n"
# all content inside this will be informed to render for Latex output
out expand_with(:output_format => 'latex')
end
def r_inspect
out ["params: #{@params.inspect}",
"name: #{@context[:name]}",
"node: #{node}",
"list: #{list}"].join("
")
end
end # Experimental
end # Zafu