Project

General

Profile

Actions

Feature #1064

closed

Using erubis instead of builtin ERb

Added by Ollivier Robert almost 16 years ago. Updated over 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2008-04-15
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid

Description

I've been testing erubis in place of the regular ERb templating system and it works fine with both RadiantCMS and Redmine. Thus it would be interesting to at least mention the possibility somewhere. What I'd also suggest is to put the following two lines at the end of config/environments/production.rb:

  1. Uncomment to use erubis instead of builtin Erb
  2. require "erubis"
Actions #1

Updated by Jean-Philippe Lang almost 16 years ago

Simply adding require "erubis" doesn't seem to have any effect, at least with Rails 2.0.

I had to follow this to enable erubis:
http://railspikes.com/2007/12/10/rendering-erubis-and-rails-2-0

it works fine with both RadiantCMS and Redmine

I can not get Redmine running with erubis 2.5.0 and Rails 2.0.2.
I get a 500 error on home page:

...
Rendering template within layouts/base
Rendering welcome/index
  ←[4;35;1mSetting Load (0.000000)←[0m   ←[0mSELECT * FROM `settings` WHERE (`se
ttings`.`name` = 'welcome_text') LIMIT 1←[0m
ERROR: compiling _run_erubis_47app47views47news47_news46rhtml RAISED compile err
or
H:/trunk_fix/app/views/news/_news.rhtml:1: syntax error, unexpected kUNLESS_MOD,
 expecting ')'
_erbout = _buf = ''; _buf << '<p>'; _buf << Erubis::XmlHelper.escape_xml( link_t
o(h(news.project.name), :controller => 'projects', :action => 'show', :id => new
s.project) + ': ' unless @project ); _buf << '

                        ^
H:/trunk_fix/app/views/news/_news.rhtml:3: syntax error, unexpected kIF_MOD, exp
ecting ')'
'; _buf << Erubis::XmlHelper.escape_xml( "(#{news.comments_count} #{lwr(:label_c
omment, news.comments_count).downcase})" if news.comments_count > 0 ); _buf << '

                                           ^
H:/trunk_fix/app/views/news/_news.rhtml:3: syntax error, unexpected ')', expecti
ng kEND
'; _buf << Erubis::XmlHelper.escape_xml( "(#{news.comments_count} #{lwr(:label_c
omment, news.comments_count).downcase})" if news.comments_count > 0 ); _buf << '
...

I think it's caused by inline statements.
Can you tell which Rails and erubis versions you're using ?

Actions #2

Updated by Jean-Philippe Lang almost 16 years ago

  • Target version deleted (0.7)
Actions #3

Updated by Jean-Philippe Lang over 15 years ago

  • Status changed from New to Closed
  • Resolution set to Invalid

Reopen if you have some feedback on using erubis.

Actions #4

Updated by ChunChang (Nagaharu) Lo over 15 years ago

I have used Erubis for few weeks, everything works fine.

My system configuration: fc9, ruby 1.8.6, ror 2.0.2.

The steps I took to replace erb:

  • install erubis with rubygem
    # gem install erubis
    Successfully installed abstract-1.0.0
    Successfully installed erubis-2.6.2
    2 gems installed
    
  • modify config/environment.rb, add:
    require 'erubis/helpers/rails_helper'
    #Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby # or Erubis::FastEruby
    #Erubis::Helpers::RailsHelper.init_properties = {}
    #Erubis::Helpers::RailsHelper.show_src = nil
    #Erubis::Helpers::RailsHelper.preprocessing = false
    
  • modify config/environments/production.rb, add:
    # Uncomment to use erubis instead of builtin Erb
    require "erubis" 
    
Actions #5

Updated by ChunChang (Nagaharu) Lo over 15 years ago

forgot to mention that i have uncommented the last line in step 2, ie:
Erubis::Helpers::RailsHelper.preprocessing = true

Actions

Also available in: Atom PDF