ruby-on-railsradiant

Raduis tags - pass variable as tag param


I've installed radiant variables extension, so now i can define var like

 <r:set_vars nav_pages="Tour: /tour | News: /news | Locations: /locations" />

And i had idea to use it in navigation snippet, something like

  <r:navigation urls="<r:puts value_for="vars[nav_pages]"/>">
    <r:normal><li><a href="<r:path />"><r:title /></a></li></r:normal> 
  </r:navigation>

certainly this will not work, at least because of quotes. Is there a way to implement this somehow? what i actually need is some common way to use a variable, accessible with tag, as a snippet argument. Or there should be some way to access variable without a tag?


Solution

  • It is indeed not possible to nest radius tags like that. There is one way to get around that, being to use double tags. I have succesfully hacked other tags this way, making them accept params from another radius tag if they are 'double' tags (<r:tag></r:tag> i.o. <r:tag/>) So with the hack in place you could do this:

    <r:navigation>
      <r:normal><li><a href="<r:path />"><r:title /></a></li></r:normal> 
      <r:urls><r:puts value_for="vars[nav_pages]"/></r:urls>
    </r:navigation>
    

    That would require calling tag.expand somewhere like this;

    urls = tag.attr['urls'] || tag.expand