Inversion publish tag.
The publish tag exports one or more subnodes to enclosing templates.
<!-- Outer template --> <html> <head> <?subscribe headers ?> </head> <body><?attr body ?></body> </html> <!-- In the body template, add a stylesheet link to the outer template's <head> --> <?publish headers ?> <link rel="stylesheet" ... /> <?end ?> <div>(page content)</div>
Create a new PublishTag with the given body.
# File lib/inversion/template/publishtag.rb, line 33 def initialize( body, line=nil, column=nil ) super key = self.body[ /^([a-z]\w+)$/ ] or raise Inversion::ParseError, "malformed key: expected simple identifier, got %p" % [ self.body ] @key = key.to_sym end
Render the tag as the body of a comment, suitable for template debugging.
# File lib/inversion/template/publishtag.rb, line 67 def as_comment_body return "Published %d nodes as %s" % [ self.subnodes.length, self.key ] end
Render the published subnodes in the context of the given renderstate, but save them for publication after the render is done.
# File lib/inversion/template/publishtag.rb, line 53 def render( renderstate ) self.log.debug "Publishing %d nodes as %s" % [ self.subnodes.length, self.key ] rendered_nodes = [] renderstate.with_destination( rendered_nodes ) do self.render_subnodes( renderstate ) end renderstate.publish( self.key, *rendered_nodes ) unless rendered_nodes.empty? return nil end
Generated with the Darkfish Rdoc Generator 2.