Skip to content

EJS (Embedded JavaScript) template compiler for Ruby

License

Notifications You must be signed in to change notification settings

leobessa/ruby-ejs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EJS (Embedded JavaScript) template compiler for Ruby

EJS templates embed JavaScript code inside <% ... %> tags, much like ERB. This library is a port of Underscore.js's _.template function to Ruby.

Pass an EJS template to EJS.compile to generate a JavaScript function:

EJS.compile("Hello <%= name %>")
# => "function(obj){...}"

Invoke the function in a JavaScript environment to produce a string value. You can pass an optional object specifying local variables for template evaluation.

If you have the ExecJS library and a suitable JavaScript runtime installed, you can pass a template and an optional hash of local variables to EJS.evaluate:

EJS.evaluate("Hello <%= name %>", :name => "world")
# => "Hello world"

© 2011 Sam Stephenson

Released under the MIT license

About

EJS (Embedded JavaScript) template compiler for Ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 56.5%
  • Ruby 43.5%