Skip to content

Instantly share code, notes, and snippets.

@bchapuis
Created May 9, 2011 21:13
Show Gist options
  • Select an option

  • Save bchapuis/963433 to your computer and use it in GitHub Desktop.

Select an option

Save bchapuis/963433 to your computer and use it in GitHub Desktop.
Dependency
<dependency>
<groupId>org.agimem</groupId>
<artifactId>jRubyHaml</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
// read the template file
InputStream stream = getClass().getClassLoader().getResourceAsStream("myFile.haml");
String template = IOUtils.toString(stream);
// initialize the options
Map<Object, Object> options = new HashMap<Object, Object>();
options.put("format", "html5");
// initialize the engine
HamlEngine engine = new HamlEngine(template, options);
// render the template
Map<Object, Object> attributes = new HashMap<Object, Object>();
attributes.put("foo", new SimpleValue("bar"));
String result = engine.render(attributes);
git clone git://github.com/bchapuis/JRubyHaml.git
cd JRubyHaml
mvn clean install
// read the template file
InputStream stream = getClass().getClassLoader().getResourceAsStream("myFile.scss");
String template = IOUtils.toString(stream);
// initialize the options
Map options = new HashMap();
options.put("syntax", "scss");
options.put("style", "compressed");
List<String> loadPaths = new ArrayList<String>();
loadPaths.add("compass/stylesheets");
loadPaths.add("my/stylesheets");
options.put("load_paths", loadPaths);
// initialize the engine
SassEngine engine = new SassEngine(template, options);
// render the template
String result = engine.render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment