Hi, Is there any way by which we can include some helper file in a template ? The helper file contains nothing but ruby helper methods which can be directly used in the erb in the template. Thanks, Niranjan
Hello, I got this worked by extending Webgen::ContentProcessor::Erb class. Added ruby methods to this class and required this file in ext\init.rb of webgen :-) Now my templates can access these methods in the erb section. Thanks, Niranjan On Sep 8, 8:20?pm, Niranjan <nirus... at gmail.com> wrote:> Hi, > > Is there any way by which we can include some helper file in a > template ? > > The helper file contains nothing but ruby helper methods which can be > directly used in the erb in the template. > > Thanks, > Niranjan > _______________________________________________ > webgen-users mailing list > webgen-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users
Thomas Leitner
2009-Sep-10 05:29 UTC
[webgen-users] Including a helper file in template file
Hi,> I got this worked by extending Webgen::ContentProcessor::Erb class. > > Added ruby methods to this class and required this file in ext\init.rb > of webgen :-) > > Now my templates can access these methods in the erb section.the proposed although currently not documented way is to * require ''webgen/context'' * add the needed methods in the Webgen::Context class This is more useful because then the helper methods are available on the context object which itself is available to all content processors. Therefore you would be able to use the methods even if you decide to switch to erubis for speed later. Having said that your approach is certainly valid and the way to go when you want to extend the functionality of the shipped classes. -- Thomas
Thanks Thomas ! I will try out your proposed solution. Regards, Niranjan On Sep 10, 10:29?am, Thomas Leitner <t_leit... at gmx.at> wrote:> Hi, > > > I got this worked by extending Webgen::ContentProcessor::Erb class. > > > Added ruby methods to this class and required this file in ext\init.rb > > of webgen :-) > > > Now my templates can access these methods in the erb section. > > the proposed although currently not documented way is to > > * require ''webgen/context'' > * add the needed methods in the Webgen::Context class > > This is more useful because then the helper methods are available on > the context object which itself is available to all content processors. > Therefore you would be able to use the methods even if you decide to > switch to erubis for speed later. > > Having said that your approach is certainly valid and the way to go > when you want to extend the functionality of the shipped classes. > > -- Thomas > _______________________________________________ > webgen-users mailing list > webgen-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users