Chris Parrish's solution to rendering partials within a Radius tag works
great. It's been almost a year since he posted it though, and I was
wondering if this functionality should be done a different way now --
i.e. does Radiant has a built-in way to handle this now?
Thanks,
- Dave
Chris Parrish wrote:
>
> [In the Model]
>
> tag "my_tag" do |tag|
> @my_tag_data = MyModel.find_by_name(tag.attr['name'])
> parse_template 'path_for/_my_template'
> end
> end
>
> private
>
> def parse_template(filename)
> require 'erb'
> template = ''
> File.open("#{MyExtensionNameExtension.root}/app/views/" + filename +
> '.html.erb', 'r') { |f|
> template = f.read
> }
> ERB.new(template).result(binding)
> end
>
>
> [In
> /vendor/extensions/my_extension_name/app/views/path_for/_my_template.html.erb]
>
> <h1><%= @my_tag_data.name -%></h1>
> <p>Value from my instance variable: <%= @my_tag_data.value -%></p>
>
> This obviously isn't full-on rails parsing so it doesn't auto-mixin
> helpers or anything fancy like that (I suppose I could require
> ActiveView::Base or some such thing) but I didn't need that much
> capability.
>
> -Chris
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant