What's the difference between eruby and erb? What considerations would drive me to choose one or the other?
My application is generating config files for network devices (routers, load balancers, firewalls, etc.). My plan is to template the config files, using embedded ruby (via either eruby or erb) within the source files to do thing...
I have been playing with Haml recently and really like the way the resulting code looks to me...the developer. I'm also not too worried about a designer being able to consume or change it...we're a small team.
That said, beginning work on a project we believe will generate quite a bit of traffic (who doesn't?). I'm concerned that there...
I have a quite old templating system written on top of ERB. It relies on ERB templates stored in database. Those are read and rendered. When I want to pass data from one template to another I use the :locals parameter to Rails render method. For setting default variables of those variables in some templates I use the defined? method whic...
I'm constructing a simple form in ERB but the HTML produced by the text_field tag makes the for attribute in the label tag invalid.
<div>
<p><%= label_tag "email[name]", "Name" %></p>
<%= text_field :email, :name, :class => "text_field" %>
</div>
Produces the HTML
<div>
<p><label for="email[name]">Name</label></p>
<input clas...
I have a FooController that responds to HTML and JS (AJAX) queries:
# app/controllers/foo_controller.rb:
class FooController < ApplicationController
layout 'foo'
def bar
respond_to do |format|
format.html # foo/bar.html.erb
format.js # foo/bar.js.erb
end
end
end
The templates to support it:
# app/views/lay...
Is there some way to determine what file currently is being rendered by Rails (2.2) in a helper method. An example result would be "/sessions/new.html.erb" or something similar.
I am trying to write a helper function that does something based on the file name that is being rendered, so I need a reliable way to obtain this information. I...
I am looking to find a librray that emulates part of the capabilities of Ruby's ERB library. ie substitute text for variables between <% and %>. I dont need the code execution part that ERB provides but if you know of something that has this I would be super appreciative.
...
Sorry for the slightly noobish question, as I am writing my first rails app. I get the idea of the layout view, but if you are using them, is there any way to include a view specific js or css file? For example, I have layouts/products.html.erb, and for products/edit.html.erb I want products_edit.css, but I don't want that css for all pr...
How can I configure tomcat to handle .rhtml pages with jruby?
I guess I should mess around with the web.xml file, but I don't know how...
(ideally, without rails, just the necessary stuff to use erb for rendering rhtml pages...)
...
I have a system that filters template files through erb. Using convention over configuration, the output files get created in a file hierarchy that mirrors the input files. Many of the files have the same names, and I was able to use the directories to differentiate them.
That plan worked until I needed to associate additional info wi...
I'm looking for a templating engine. What are the important factors to consider when choosing among Haml, Sass/Compass and erb?
...
Question: Instead of getting transformed output from my ERB template, is there a parameter, setting or hack I can use that will output the raw ruby code that gets generated right before the transformation runs?
Rationale: I am having trouble figuring out the problem with an ERB template syntax error, and I would like to see the plain ru...
I've been using Netbeans for Rails and like it a lot, considering how little I paid for it. But something that bothers me is that when I'm editing an RHTML or ERB file, it doesn't do the code autocomplete - or at least not reliably. Sometimes it shows the appropriate variables and methods that are available on an object after you type th...
I have the Rails partial which has a few such checks:
<%= if local_assigns.has_key?(:show_blabla) && show_blabla == false %>
blabla
<% end %>
I think that sort of hides the real list of parameters which are used by such partial, and hey local_assigns is not in documentation even.
What are your thoughts?
...
I have a model like this:
class Transaction < ActiveRecord::Base
def amount
self[:amount].abs
end
def transaction_type
read_attribute(:amount) > 0 ? :credit : :debit
end
def transaction_type=(type)
if type == :credit || type == 'credit'
self[:amount] = amount.abs
elsif type == :debit || type == 'debit'
...
there is a line displayed within <pre>
<%= h @stories.inspect %>
and the output was too long, so i changed it to
<%= #h @stories.inspect %>
<% @stories.each do |s| %>
<%= h s.inspect %>
<% end %>
(commenting out the first line). now the code will fail to compile... saying
compile error
/Users/winterheat/ror/shov2/app/views/sto...
it seems that on Rails or erb, the only way to output anything is by <%= %>
<% puts "hello" %> won't work, unlike PHP.
is there any other method at all?
...
Hello!
I need ERB (Ruby's templating system) for templating of non-HTML files.
(Instead, I want to use it for source files such as .java, .cs, ...)
How do I "execute" Ruby templates from command line?
...
I'm looking for a way to parse an xml/html document in ruby, which contains ERB style tags <% %> with ruby code inside. REXML, the built in XML parser won't allow me to do this.
I'm aware that I might be able to with a third party library like hpricot, but I'd like to avoid any external dependencies.
Is there a way I could get REXML t...
My index.html page for my project needs some Ruby code so I need to change it to a .erb extension. How do I configure Rails to identify the index.html.erb file as the starting page of the project instead of the index.html file?
...