-
Notifications
You must be signed in to change notification settings - Fork 0
Creates a hook that allows you to make changes to a template once after it's rendered.
License
jenmei/afterrender
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
AfterRender =========== You can use this plugin to post-process Rails templates (originally worked for 1.2.6; it's now updated for Rails 2 and only tested with Rails 2.1.1) have been rendered. This has not been thoroughly tested ... it works well enough for me at the moment. You can use AfterRender in two ways. Either you can write your own code that you want to apply after rendering, or you can use the default. If you want the default (which adds comments to generated HTML showing which template you're in, as well as showing locals), then set AFTER_RENDER=true in the proper environment file (e.g. at the bottom of development.rb). Otherwise, you can set AFTER_RENDER equal to a proc or a lambda, like so: AFTER_RENDER = lambda { | h | "<!-- code generated by: #{h[:template_path]} -->\n" + rendered_template + "<!-- end of code generated by: #{h[:template_path} -->\n" } Here's the full list of values in the Hash that's passed to AFTER_RENDER: :template_path => The path to the template being rendered. :locals => The locals passed to the template, including the the one passed as :object. :rendered_template => The HTML generated after rendering the template. :parent_template_path => The path to the template that this one is nested in, if applicable. :parent_template_path is a guess based on the call stack. It just looks for the first thing in app/views that was called before the current template being rendered. Tested on Rails 2.1.1 only.
About
Creates a hook that allows you to make changes to a template once after it's rendered.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published