hello, I am trying to have some simple HTML to be used as a placeholder page for new servers users in a small camping application (basically with using the main site layout plus the current date and time :) )and I was wondering if the correct way is to rewrite the whole html using markaby or I should use the hack def layout text '' .... html inside where the only ruby code would be Today is ''+Time.now.asctime+'' '' or if there is any way that I don''t know to have inline templates/use erb ? thanks a lot ! Best Regards David -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20120814/3a2f5b16/attachment.html>
See magnus''s post at http://rubyforge.org/pipermail/camping-list/2010-August/001413.html for info on using the haml and erb support built in to Camping. Also note that you don''t need to ''render'' anything. You can just set @body to whatever string you want in your controller, or even return an IO or Array of stuff to turn in to strings. If you return an IO like a file or an a url opened with open-uri the server will automatically stream out the information. ? Jenna On Tuesday, 14 August 2012 at 1:44 PM, gurugeek wrote:> hello, > I am trying to have some simple HTML to be used as a placeholder page for new servers users in a small camping application (basically with using the main site layout plus the current date and time :) )and I was wondering if the correct way is to rewrite the whole html using markaby or I should use the hack > > def layout > text '' > > .... html inside > where the only ruby code would be Today is ''+Time.now.asctime+'' '' > > or if there is any way that I don''t know to have inline templates/use erb ? > > thanks a lot ! > Best Regards > David > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org (mailto:Camping-list at rubyforge.org) > http://rubyforge.org/mailman/listinfo/camping-list > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20120814/a84cea6f/attachment.html>
Well, the elegant (and perhaps philosophically correct) way is to use Markaby. In general, I try to avoid placing raw HTML into my Ruby code. If you don''t want to rewrite your HTML, you can use ERB templates. Without being redundant, more info on how to make this work can be found here: http://rubyforge.org/pipermail/camping-list/2010-August/001413.html Disclaimer: I haven''t tried it myself. -- Trevor Johns http://tjohns.net -- Trevor Johns http://tjohns.net On Monday, August 13, 2012 at 8:44 PM, gurugeek wrote:> hello, > I am trying to have some simple HTML to be used as a placeholder page for new servers users in a small camping application (basically with using the main site layout plus the current date and time :) )and I was wondering if the correct way is to rewrite the whole html using markaby or I should use the hack > > def layout > text '' > > .... html inside > where the only ruby code would be Today is ''+Time.now.asctime+'' '' > > or if there is any way that I don''t know to have inline templates/use erb ? > > thanks a lot ! > Best Regards > David > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org (mailto:Camping-list at rubyforge.org) > http://rubyforge.org/mailman/listinfo/camping-list > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20120814/9328213b/attachment.html>
Jenna - Trevor, many thanks for this. It works fine but perhaps I should stick to markaby for the example page so it would be easier to have everything in one file and new users can learn how to use it? Best Regards David On Aug 14, 2012, at 6:28 AM, Jenna Fox <a at creativepony.com> wrote:> See magnus''s post at http://rubyforge.org/pipermail/camping-list/2010-August/001413.html for info on using the haml and erb support built in to Camping. > > Also note that you don''t need to ''render'' anything. You can just set @body to whatever string you want in your controller, or even return an IO or Array of stuff to turn in to strings. If you return an IO like a file or an a url opened with open-uri the server will automatically stream out the information. > > ? > Jenna > > On Tuesday, 14 August 2012 at 1:44 PM, gurugeek wrote: > >> hello, >> I am trying to have some simple HTML to be used as a placeholder page for new servers users in a small camping application (basically with using the main site layout plus the current date and time :) )and I was wondering if the correct way is to rewrite the whole html using markaby or I should use the hack >> >> def layout >> text '' >> .... html inside >> where the only ruby code would be Today is ''+Time.now.asctime+'' '' >> >> or if there is any way that I don''t know to have inline templates/use erb ? >> >> thanks a lot ! >> Best Regards >> David >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20120814/d22f943f/attachment.html>
Markaby is ''canon'' so to speak, if it is a camping tutorial or something like that. It''s best supported as we all depend on it, and it''s a great option for beginners (and old hats like me) as it makes cross site scripting vulnerabilities much less common. If twitter used markaby instead of erb I doubt Judofyr''s twitter worm would have worked. ? Jenna Fox On Wednesday, 15 August 2012 at 1:56 AM, gurugeek wrote:> Jenna - Trevor, > many thanks for this. It works fine but perhaps I should stick to markaby for the example page so it would be easier to have everything in one file and new users can learn how to use it? > > Best Regards > David > > > > On Aug 14, 2012, at 6:28 AM, Jenna Fox <a at creativepony.com (mailto:a at creativepony.com)> wrote: > > See magnus''s post at http://rubyforge.org/pipermail/camping-list/2010-August/001413.html for info on using the haml and erb support built in to Camping. > > > > Also note that you don''t need to ''render'' anything. You can just set @body to whatever string you want in your controller, or even return an IO or Array of stuff to turn in to strings. If you return an IO like a file or an a url opened with open-uri the server will automatically stream out the information. > > > > ? > > Jenna > > > > > > On Tuesday, 14 August 2012 at 1:44 PM, gurugeek wrote: > > > > > hello, > > > I am trying to have some simple HTML to be used as a placeholder page for new servers users in a small camping application (basically with using the main site layout plus the current date and time :) )and I was wondering if the correct way is to rewrite the whole html using markaby or I should use the hack > > > > > > def layout > > > text '' > > > > > > .... html inside > > > where the only ruby code would be Today is ''+Time.now.asctime+'' '' > > > > > > or if there is any way that I don''t know to have inline templates/use erb ? > > > > > > thanks a lot ! > > > Best Regards > > > David > > > > > > _______________________________________________ > > > Camping-list mailing list > > > Camping-list at rubyforge.org (mailto:Camping-list at rubyforge.org) > > > http://rubyforge.org/mailman/listinfo/camping-list > > > > > > > > > > > > _______________________________________________ > > Camping-list mailing list > > Camping-list at rubyforge.org (mailto:Camping-list at rubyforge.org) > > http://rubyforge.org/mailman/listinfo/camping-list > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20120815/f87edc00/attachment.html>