erb

Continuously Check Time

Firstly, how can I have jQuery continuously check the time, and add an id to a <div> tag if the current time is in between two set times? I'm making a clock for a school (where the clock is a website sent over cable to TVs in every room), where each period is expressed like this: <div class="period 1">Period 1: 7:32-8:14</div> I'm get...

Is there a way to list the available variables in an Ruby ERB template?

Hi All, Suppose I have a Ruby ERB template named my_template.html.erb, and it contains the following: <div><%= @div_1 %></div> <div><%= @div_2 %></div> <div><%= @div_3 %></div> Is there a way I can programatically list out all the available variables in the template? For example, the following method: def list_out_variables templ...

How to write a view helper that renders works with HAML and ERB?

Hi I am working on a gem that defines a few view helpers and it heavily relies on concat and capture methods but I've recently discovered it doesn't work with HAML (haven't tested thoroughly, but so far doesn't render concat(nated) stuff). I read somewhere there was a haml_concat version of concat. So If I just need to change my concat ...

SQL templating engine to mix SQL with dynamic language? (similar to Ruby's erb)

Has anyone comes across a SQL templating engine which allows one to mix SQL with a dynamic language like Ruby or Python? I'm looking for something similar to Ruby erb templates. For example, in Ruby on Rails you can have various templates for a view: customers.html.erb (html + ruby) customers.js.erb (javascript + ruby) Though I want s...

Better syntax highlighting for js.erb files in Textmate

I'd like Textmate to highlight Ruby syntax inside <% %> tags in *.js.erb files (like it does in *.html.erb files). Right now it looks like this: As you can see, everything within the quotes is treated like a regular JS string – annoying. ...

In Rails 2 yielding a block in a helper a method renders partial?

Rails 2.2.2 _competition.html.erb <p>This is packed</p> <% pack do %> // some javascript <% end %> competitions_helper.rb def pack(&block) yield + 'PACKED' end However 'PACKED' does not get appended to my javascript string, its as if pack do has no effect. It seems like there is some oddness going off with context of the blocks ...

render erb from database into view problem please help!

hi all i am saving some erb in my database and rendering it in the view like this: erb = ERB.new(content) render :text => erb.result I am getting errors when trying render erb that has the image_tag in the erb saved in the database. The error is : undefined method `image_tag' for main:Object Anyone help on this ? i also get the...

TextMate js.erb: toggle <%= %>, <% %>

I'm using a js.erb template to render some jQuery. When editing an html.erb file in TextMate, I frequently use the convenient key combo, ctrl+>, to create and then toggle the following tags: <%= %> <% %> <%- -%> <%# %> This shortcut doesn't work by default when editing js.erb files. In the Bundle Editor, I found a snippet called "...

What is wrong in this ruby statement?

I am trying to do something when I am connecting to my own server(local). I found request.env from the website, so I am using that array to compare my IPs. <% if request.env['HTTP_HOST']!="127.0.0.1" puts request.env['HTTP_HOST'] else puts "its Local!" end %> When I run above in rails3, I get nothing printed... I am new t...

Ruby: erb throwing error "`result': can't convert String into Integer (TypeError)"

Quick background: I'm setting up a quick and dirty templating scheme where all of my template files are named '*.erb'. the fill in data resides in a yaml file. Output is to files with the name of the template, minus '.erb'. I haven't done much work with erb, and I'm getting the error "`result': can't convert String into Integer (TypeErr...

Best way to build a Javascript Array of Objects on Ruby on Rails

I have this but I'm pretty sure that is not the best way to build it up. var dogs = { 'names' : ["a", "b", "c"], 'images': [ <% @dogs.images.each do |image| %> { 'thumb' : '<%= image.thumb %>', 'medium' : '<%= image.medium %>', } <%= "," unless(@dogs.images.last.id == image.id) %> <% end %> ] } Thanks for your he...

How to create PHP/JSP/ERB tags using XSLT?

I have a bunch of XML files which I use to generate HTML pages. Those pages ultimately get marked up (by hand) with some <%= %> tags and made into Ruby .erb templates. Is there a way to generate the special tags <?php ?> or <%= %> directly during the XSL transform? I've tried using a <![CDATA[ ... ]]> block, but then the output generat...

Frames in erb Rails

Hi, I need the information to create frames in erb rails. I need to display the links in a frames instead of provide as link to new window. Eg. a href="taxas?[gm]=<%= prefer.genus_name %>&[sp]=<%= prefer.sp_epithet%>" target="new">Link /a This should be modified as frame href="taxas?[gm]=<%= prefer.genus_name %>&[sp]=<%= prefer.s...

recognize Ruby code in Treetop grammar

I'm trying to use Treetop to parse an ERB file. I need to be able to handle lines like the following: <% ruby_code_here %> <%= other_ruby_code %> Since Treetop is written in Ruby, and you write Treetop grammars in Ruby, is there already some existing way in Treetop to say "hey, look for Ruby code here, and give me its breakdown" with...