README.md in skim-0.8.6 vs README.md in skim-0.9.0

- old
+ new

@@ -1,27 +1,33 @@ -Skim [ ![Build status](http://travis-ci.org/jfirebaugh/skim.png) ](http://travis-ci.org/jfirebaugh/skim) +Skim [ ![Build status](https://travis-ci.org/jfirebaugh/skim.png) ](https://travis-ci.org/jfirebaugh/skim) ==== Take the fat out of your client-side templates with Skim. Skim is the [Slim](http://slim-lang.com/) templating engine with embedded CoffeeScript. It compiles to JavaScript templates (`.jst`), which can then be served by Rails or any other Sprockets-based asset pipeline. # Usage `gem install skim`, or add `skim` to your `Gemfile` in the `:assets` group: - group :assets do - gem 'skim' - end +```ruby +group :assets do + gem 'skim' +end +``` Create template files with the extension `.jst.skim`. For example, `test.jst.skim`: - p Hello #{@world}! +```jade +p Hello #{@world}! +``` In your JavaScript or CoffeeScript, render the result, passing a context object: - $("body").html(JST["test"]({world: "World"})); +```js +$("body").html(JST["test"]({world: "World"})); +``` Order up a skinny latte and enjoy! # Caveats @@ -64,37 +70,47 @@ Like Slim, Skim escapes dynamic output by default, and it supports the same `==` and `#{{}}` syntaxes for bypassing escaping. In addition, the special `safe` method on the context object tells Skim that the string can be output without being escaped. You can use this in conjunction with `escape` context method to selectively sanitize parts of the string. For example, given the template: - = @linkTo(@project) +```jade += @linkTo(@project) +``` you could render it with the following context: - JST["my_template"] - project: { id: 4, name: "Crate & Barrel" } - linkTo: (project) -> - url = "/projects/#{project.id}" - name = @escape project.name - @safe "<a href='#{url}'>#{name}</a>" +```coffeescript +JST["my_template"] + project: { id: 4, name: "Crate & Barrel" } + linkTo: (project) -> + url = "/projects/#{project.id}" + name = @escape project.name + @safe "<a href='#{url}'>#{name}</a>" +``` to produce: - <a href='/projects/4'>Crate &amp; Barrel</a> +```html +<a href='/projects/4'>Crate &amp; Barrel</a> +``` ## The Skim asset By default, all you need to do to start using Skim is add it to your Gemfile. Skim will embed a small amount of supporting code in each generated template asset. You can remove this duplication by manually including Skim's asset, and setting Skim's `:use_asset` option to true. In Rails, this can be done by adding the following to `application.js`: - //= require skim +```js +//= require skim +``` And the following in an initializer: - Skim::Engine.default_options[:use_asset] = true +```ruby +Skim::Engine.default_options[:use_asset] = true +``` # License (MIT) Copyright (c) 2012 John Firebaugh