Displaying 20 results from an estimated 20000 matches similar to: "Passing ERB block to helper"
2006 Jul 25
3
about ERB sample
Hi list:
I run the ri''s ERB doc 1st sample
1. require ''erb''
2. x = 42
3. template = ERB.new <<-EOF
4. The value of x is:
5. EOF
6. puts template.result(binding)
the doc say it will print
"The value of x is: 42"
but my irb print "nil" and there is a
"=> #<ERB:0x2970b24
2012 Apr 24
3
How to increment variable in erb template ?
Hi'',
I''m looking for a way to increment variable in template (erb file).
I tried this, but it didn''t work
Compteur <%= compteur %>
> <% compteur = compteur + 1 %>
> Compteur <%= compteur %>
>
I''ve got this error :
> Error 400 on SERVER: Failed to parse template test/test.erb: undefined
> method `+'' for
2006 Apr 19
4
emacs rails 0.39
Testing version of Emacs Rails (http://rubyforge.org/projects/emacs-rails/)
was released. If you have some suggestion or you find some bugs please
inform us.
Features:
* Management of WEBrick/Mongrel
* Display color log file
* Toggle Switch between Action/View and other file (tests, helpers)
automaticly or with menu
* Switching to file from current line f.e. from redirect_to :controller =>
2011 Nov 18
2
Are tildes actually valid in templates or is this a bug?
Hi all,
First off, we''re running Puppet 2.7.6 with Ruby 1.8.7 on CentOS 6.0.
Now, I''m using tildes in a template to prevent newlines from appearing but
ruby/puppet is choking on them.
*/tmp/puppet$ cat test.erb*
Line 1: Line 2 will exist if running on CentOS.
<% if operatingsystem == "CentOS" ~%>
Line 2: Yay, we''re running CentOS.
<% end ~%>
2011 Nov 10
1
url helper in model.js.erb.cofee (Sprockets::Context)
hello,
I am writing a js/coffee file that gets erb handling and I need to use
a url helper inside this file
if write
..
url: ''<%= url_for(:action => :index) %>''
I get an error:
NoMethodError Exception: undefined method `url_for'' for #<#<Class:
0xbdbb068>:0xeed1eb8>
>>self.class
#<Class:0xbdbb068> < Sprockets::Context
How do I
2008 Dec 20
4
Accessing rails helpers when processing erb snippets
I need to be able to merge a lot of content for web pages, along with
links to other pages taken from a list of categories. The text that goes
with each category can be different depending on the context that it''s
displayed in.
I could do this by having a whole stack of *.html.erb files which hold
the static content and access the Rails helpers to pull in stuff from
the database and
2011 Jan 22
1
uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError)
I am a new to ruby and rails and am trying to refactor some code with
rspec and have run into a problem that has stumped me for a few days and
I have searched google and ruby/rails forums to no avail so I really
hope somebody can help me out with this problem which I think may be
caused by a rails config problem. Anyway, I used ''rails new myapp'' to
make a new rails project and
2006 Feb 20
7
Native erb lacks -%>, where is Rails'' erb?
Native ERB in ruby, and eruby, seem to lack the -%> feature for
suppressing trailing newlines. Thus
erb -n script
gives errors. Where is Rails ERB so I can invoke it directly?
Thank you
Hugh
2007 Jan 19
4
Rendering with erb
Hi, I thought it would be fun to try to write a render method that
uses erb for rending. I''m not much of a programmer, but I still like
to try:
module Test
require ''erb''
def render(m)
ERB.new(IO.read("templates/layout.html")).result(binding) do
ERB.new(IO.read("templates/#{m}.html")).result(binding)
end
end
end
This
2006 Jun 27
5
Can''t call public application.rb method from ERb template
All,
I have a left navigation partial that I want to dynamically generate CSS
classes for based on the current controller action.
In my ERb template, I have
<DIV class="<%= get_menu_display_style(''login_form'') %>">
In application.rb, I have the method get_menu_display_style defined as:
public
def get_menu_display_style(action_requested)
2011 Mar 09
1
" instead of " in js code rendered by erb
Having problems rendering javascript in erb file. Thanks for
suggestions.
//layout erb file
(function() {
...
var widget_properties = {};
<%= content_for?(:extend_widget) ? "widget_properties = " +
yield(:extend_widget) : '''' %>
...
})();
//view erb file
<% content_for :extend_widget do %>
extend = {
_init: function() {
2006 Apr 25
5
markaby or erb?
Guys,
We''re embarking on a new dev project, and I''m curious....why would one
choose markaby over erb? I for one am no fan of the erb syntax, but
aside from that it''s similar to other technologies I''ve used in the
past: PHP, JSP, ASP, etc.
Why would one choose markaby over erb? What are the benefits? What are
the drawbacks? Is there anything remarkable
2007 Sep 28
2
RoR uses something rather than erb or eRuby?
it seems that RoR doesn''t use erb or eRuby to generate its output for
rhtml?
the program erb and the description of eRuby at
http://www.eruby.info
both said that
<% print "foo bar" %> or <% puts "hello" %>
will be placed into the output...
but currently for RoR, it won''t...
only <%= expr %> is doing it and it cannot be print or
2006 Jan 22
9
ERROR: undefined method `h'' for ERB::Util:Module
ERROR: undefined method `h'' for ERB::Util:Module
i get above error when i use
ERB::Util.h(content)
in my controller''s action.
can any one one tell me how to use this ''h'' method within controller?
thanks,
Jigar Gosar
http://jigar.org
--
Posted via http://www.ruby-forum.com/.
2011 Oct 12
4
How to access controller's instance variable in a js.erb loaded by javascript_include_tag?
Hello!
In rails 3.1 app I have a controller UsersController with ''show'' action.
show.html.erb contains:
<% content_for(:head) do %>
<%= javascript_include_tag ''myscript'' %>
<% end %>
<p>Hello @user.name</p>
And I have this in myscript.js.erb
$jQuery(document).ready(function() {
alert(<%= @user.name %>);
});
@user is being
2007 May 28
2
helper with block compile error
HI,
i''m trying to write a helper that replaces link_to_remote that
accepts a block but it gets a compile error in the template:
I don''t know what I''m doing wrong... TIA
# application_helper.rb
def link_block_to_remote( options = {}, html_options = {}, &block)
concat(link_to_remote(capture(&block), options, html_options),
block.binding)
end
# in
2006 Mar 15
3
Special characters in ERB
I''m pulling text out of a database that contains special characters,
like the trademark sign. For example, a typical string might be like this:
string_from_database => "Some Special Brand\231 is for sale this
Thursday through Friday."
The \231 is the trademark sign (TM). ERB converts this to question
marks. So, my question is -- how can I get it to display the trademark
2010 Jun 10
1
printing in middle of an erb file
Hello,
I''m having a problem to output things in the right order with erb1.9
and lighttpd . I don''t know if it''s the normal behaviour of erb but
this is how it works for me:
Content of my ERB file: test{<%= 1 %>2<% puts 3 %>}
On my web browser I get this output:
3
test{12}
puts or print comes before any text.. Do you know wich function instead
of
puts
2012 Nov 27
1
controller not rendering existing js.erb file
In my PlaceController, I have a search method, called remotely from a form
the method is executed, but rendering is not executed as the template is
stated as missing ..
but it''s there ...
post :search, :locale => I18n.locale, :format => :js, :country =>
"United"
Error: test_should_search_places(Backoffice::PlacesControllerTest)
ActionView::MissingTemplate:
2007 Apr 03
4
Replacing ERB with Erubis
Hey guys,
I''ve been hearing a lot about erubis: http://www.kuwata-lab.com/erubis/
Especially about how much faster it is than straight ERB.
In their Ruby on Rails support docs: http://www.kuwata-lab.com/erubis/users-guide.05.html#topics-rails
They state that with a few added lines to your environment.rb it will
replace ERB completely.
I''m wondering if anyone has done this in