Questions tagged [erubis]

For questions about Erubis, a fast, secure, and very extensible implementation of Embedded Ruby (eRuby).

Erubis has the following features:

  1. Very fast, almost three times faster than ERB and even 10% faster than eruby
  2. Multi-language support (Ruby/PHP/C/Java/Scheme/Perl/Javascript)
  3. Auto escaping support
  4. Auto trimming spaces around '<% %>'
  5. Embedded pattern changeable (default '<% %>')
  6. Enable to handle Processing Instructions (PI) as embedded pattern (ex. '')
  7. Context object available and easy to combine eRuby template with YAML datafile
  8. Print statement available
  9. Easy to extend and customize in subclass

Erubis is implemented in pure Ruby. It requires Ruby 1.8 or higher. Erubis now supports Ruby 1.9.

Read more

25 questions
70
votes
5 answers

Using a Rails helper method within a javascript asset

Is there any way to use a Rails helper method, more specifically, a path helper method within a javascript asset file. This file foo.js.coffee.erb $('#bar').val("<%= create_post_path %>") I would love it if I could get from…
axsuul
  • 7,370
  • 9
  • 54
  • 71
8
votes
5 answers

How to comment code in Rails views?

As I'm playing with Rails and developing views I often want to comment out code. Simple enough with classes & models but views are a bit more tricky. What's best way to comment code in a view so it's not interpreted by, well, anything... HTML…
Meltemi
  • 37,979
  • 50
  • 195
  • 293
7
votes
2 answers

Ruby on Rails: What are Erubis' disadvantages and why isn't it packaged with Rails by default? How to set it up?

I just discovered Erubis, a replacement for the default view renderer for Ruby on Rails. However, from what I can tell from reading about it, it's superior across the board. It is much faster. It has many more options. It can prevent cross site…
William Jones
  • 18,089
  • 17
  • 63
  • 98
6
votes
4 answers

Erubis block helper throwing error with concat

I have a couple of block helpers, here's a simple example of what I'm doing: def wrap_foo foo, &block data = capture(&block) content = "
#{data}
" concat( content ) end I'm…
DEfusion
  • 5,533
  • 5
  • 44
  • 60
5
votes
3 answers

in sinatra using erubis, default setting escape_html is true. sometimes hava to unescape

In Sinatra, using erubis, the default setting for escape_html is true. But sometimes I want to to unescape, because, I do not want to add too much escape_html. Don't repeat yourself. :) helpers: def raw(string) …
kennx9
  • 63
  • 2
  • 4
4
votes
1 answer

How to trim leading whitespace with `<%=` in ERB templates in Rails that end up in `pre` elements?

(As far as I have researched here, this is not a duplicate question. Trimming spaces -- often trailing newlines -- is being discussed for <%- or -%>, but not for <%=. It could be a minor defect in Erubi template engine as well, the one being used by…
Jochem Schulenklopper
  • 6,452
  • 4
  • 44
  • 62
4
votes
4 answers

Is there any way to disable Erubis from printing "** Erubis 2.6.5" when starting the Rails environment?

I have several frequent Cron jobs that are run via Rake and the output of those jobs are e-mailed (via a MAILTO). Due to the fact that these tasks load the Rails environment (which includes Erubis) they always prints out "** Erubis 2.6.5" on…
Nathan
  • 41
  • 1
3
votes
1 answer

Rails HTML escapes plaintext emails

So, Rails has the wonderful capability of sending plaintext emails alongside HTML emails. You just put up a .text.erb alongside your .html.erb. I put up an application to this effect here: https://github.com/cairo140/rails-email-test. Just download…
Steven
  • 17,796
  • 13
  • 66
  • 118
3
votes
0 answers

How to use partial views using the Erubis gem

I am not using Ruby on Rails, this is a stand alone app using the the erubis gem. I have a few template files which I use for generating a static website, and would like to separate the header, body, and footer sections in the files. For example <%=…
hak8or
  • 488
  • 2
  • 9
  • 28
2
votes
2 answers

Error traces in Erubis

By default, when an an Erubis template raises an error, you get something like this: (erubis):32:in `evaluate': compile error (SyntaxError) (erubis):30: syntax error, unexpected ')', expecting ']' (erubis):32: unterminated string meets end of…
rlkw1024
  • 6,455
  • 1
  • 36
  • 65
2
votes
3 answers

Using Erubis 2.6.2 with Rails 2.2.2 is incompatible?

Supposedly installing erubis is as simple as: gem install erubis # And in environment.rb: require 'erubis/helpers/rails_helper' But I haven't found this to be so. Note that there are no evident errors in my code; it runs just fine and dandy with…
Robert K
  • 30,064
  • 12
  • 61
  • 79
2
votes
1 answer

Ruby Rendering Specific Variable

I have a template which contains various variables for rendering. Is there a way i can render specific variables in the template without exception. e.g. template_content = "My name is <%=firstname%>. I live at <%=location%>" variable_hash =…
abrocks
  • 171
  • 13
2
votes
0 answers

Is erubis still faster than erb?

I'm choosing a templating system for a gem, so I was thinking to use Erubis which it seems to be faster than ERB, but the last released version is from 2011. As ERB is integrated into the ruby stdlib, I guess their performance has been improved…
Alter Lagos
  • 12,090
  • 1
  • 70
  • 92
1
vote
1 answer

Bundler::GemNotFound: Could not find erubi-1.7.0 in any of the sources

Hello i have a problem with bundle. I am actually developing a rails app in a docker (dockerized rails) I need to add the bcrypt gem, but when i add this gem and run bundle install ans bundle update i got this error message : Thanks for help web_1 …
1
vote
1 answer

How to use erubis with mamp

i found out erubis, the "fast, secure, and very extensible implementation of eRuby", now after install through gem install erubis, my question is how to run in on mac? especially on mamp? i been no luck finding answer on google so anyone know how?
devlim
  • 11
  • 2
1
2