I haven't tried it, but that looks like it should work. But see also
the "js" method, as exemplified in the prototype given with "ramaze
create". It's a shortcut to make "<script src....>".
--
Pistos
http://blog.purepistos.net
It's from the XHTML helper:
http://github.com/manveru/ramaze/blob/master/lib/ramaze/helper/xhtml.rb
so you can use: #{ js_for(*@page_javascripts) }, and simply push the
ones that you need currently inside (of course you'll need to set
@page_javascripts).
> Thanks again,
>
> Scott
>
> On Fri, Jun 5, 2009 at 7:56 AM, <jesusisramaz...@geoshell.com>
> wrote:
>>
>> 2009/6/5 Scott LaBounty - slab...@gmail.com:
>> > @page_javascript = "page1.js"
>> >
>> > and then in the layout do something like:
>> >
>> > <script src="#@page_javascript" type="text/javascript"></script>
>>
>> I haven't tried it, but that looks like it should work. But see also
>> the "js" method, as exemplified in the prototype given with "ramaze
>> create". It's a shortcut to make "<script src....>".
>>
>> --
>> Pistos
>> http://blog.purepistos.net
> --
> Scott
> http://steamcode.blogspot.com/
--
^ manveru
> Hmmm...
>
> I put this:
>
> @page_javascript = "js/admin.js"
>
> in the controller and this in the layout:
>
> <?r #{js(@page_javascript)} ?>
#{ js @page_javascript }
the <?r #{ ?> will start a comment, which will mess up the rest of the template
evaluation.
--
^ manveru
Ruby | /home/slabounty/RamazeTutorial/Poll/layout/page.xhtml : in binding , line 17 |
---|---|
Web | GET localhost/ |
<?r ?> is transformed via:
.gsub!(/<\?r\s+(.*?)\s+\?>/m, "#{STOP} \\1; #{ADD} #{START}")
e = Etanni.new('hi there <?r #{foo} ?> bar')
puts e.compile
Will result in:
_out_ =
<<E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82.chomp
hi there
E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82
#{foo}; _out_ <<
<<E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82.chomp
bar
E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82
_out_
As you can see, the #{foo} simply starts a commented line, so the
following heredoc is dropped, if there are no more <?r ?> afterward,
nothing from what follows will be show anymore. As a general rule,
don't use comments inside the ruby processing instructions. You want
output, so use proper string interpolation:
e = Etanni.new('hi there #{foo} bar')
puts e.compile
Will result in:
_out_ =
<<E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82.chomp
hi there #{foo} bar
E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82
_out_
And "hi there #{foo} bar" will properly interpolate in the following eval.
Etanni is a very simple templating engine, if you don't understand
what i just wrote, read the source (all 4 lines of it), and learn, or
stop using this undocumented, obscure, and hardly used engine, and use
something like ERB which gives you <%# %> to make comments, <%= %> for
interpolation, and <% %> for ruby, no confusing interpolation.
> Anyway ... now I get:
>
> NoMethodError at /
>
> undefined method `js' for #<MainController:0x9242b70>
Because it's a helper, you have to use helper(:xhtml) in your
controller before using it.
--
^ manveru