tilt 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -26,6 +26,7 @@ Support for these template engines is included with the package:
26
26
  Interpolated String .str none (included ruby core)
27
27
  Haml .haml haml
28
28
  Sass .sass haml
29
+ Less CSS .less less
29
30
  Builder .builder builder
30
31
  Liquid .liquid liquid
31
32
  Mustache .mustache mustache
@@ -11,10 +11,12 @@ documentation on each supported template engine is provided below.
11
11
  * [Liquid](#liquid) - `Tilt::LiquidTemplate`
12
12
  * [Mustache](#mustache) - `Tilt::MustachTemplate`
13
13
 
14
- Tilt includes support for simple text formats in addition to
15
- programmable template languages. These typically do not support
16
- scope or locals but often support rendering options.
14
+ Tilt includes support for CSS processors like [lesscss](http://lesscss.org)
15
+ and [sass](http://sass-lang.com/), in addition, it also supports simple
16
+ text formats.
17
17
 
18
+ * Less - `Tilt::LessTemplate`
19
+ * Sass - `Tilt::SassTemplate`
18
20
  * [Markdown](#markdown) - `Tilt::RDiscountTemplate`
19
21
  * [RDoc](#rdoc) - `Tilt::RDocTemplate`
20
22
 
@@ -1,5 +1,5 @@
1
1
  module Tilt
2
- VERSION = '0.4'
2
+ VERSION = '0.5'
3
3
 
4
4
  @template_mappings = {}
5
5
 
@@ -325,6 +325,25 @@ module Tilt
325
325
  register 'sass', SassTemplate
326
326
 
327
327
 
328
+ # Lessscss template implementation. See:
329
+ # http://lesscss.org/
330
+ #
331
+ # Less templates do not support object scopes, locals, or yield.
332
+ class LessTemplate < Template
333
+ def initialize_engine
334
+ require_template_library 'less' unless defined? ::Less::Engine
335
+ end
336
+
337
+ def compile!
338
+ @engine = ::Less::Engine.new(data)
339
+ end
340
+
341
+ def evaluate(scope, locals, &block)
342
+ @engine.to_css
343
+ end
344
+ end
345
+ register 'less', LessTemplate
346
+
328
347
  # Builder template implementation. See:
329
348
  # http://builder.rubyforge.org/
330
349
  class BuilderTemplate < Template
@@ -0,0 +1,20 @@
1
+ require 'contest'
2
+ require 'tilt'
3
+
4
+ begin
5
+ require 'less'
6
+
7
+ class LessTemplateTest < Test::Unit::TestCase
8
+ test "is registered for '.less' files" do
9
+ assert_equal Tilt::LessTemplate, Tilt['test.less']
10
+ end
11
+
12
+ test "compiles and evaluates the template on #render" do
13
+ template = Tilt::LessTemplate.new { |t| ".bg { background-color: #0000ff; } \n#main\n { .bg; }\n" }
14
+ assert_equal ".bg, #main { background-color: #0000ff; }\n", template.render
15
+ end
16
+ end
17
+
18
+ rescue LoadError => boom
19
+ warn "Tilt::LessTemplate (disabled)\n"
20
+ end
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'tilt'
6
- s.version = '0.4'
7
- s.date = '2009-12-13'
6
+ s.version = '0.5'
7
+ s.date = '2010-01-15'
8
8
 
9
9
  s.description = "Generic interface to multiple Ruby template engines"
10
10
  s.summary = s.description
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  test/tilt_erbtemplate_test.rb
26
26
  test/tilt_erubistemplate_test.rb
27
27
  test/tilt_hamltemplate_test.rb
28
+ test/tilt_lesstemplate_test.rb
28
29
  test/tilt_liquidtemplate_test.rb
29
30
  test/tilt_mustachetemplate_test.rb
30
31
  test/tilt_rdiscounttemplate_test.rb
@@ -46,6 +47,7 @@ Gem::Specification.new do |s|
46
47
  s.add_development_dependency 'mustache'
47
48
  s.add_development_dependency 'rdiscount'
48
49
  s.add_development_dependency 'liquid'
50
+ s.add_development_dependency 'less'
49
51
 
50
52
  s.extra_rdoc_files = %w[COPYING]
51
53
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilt
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.4"
4
+ version: "0.5"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-13 00:00:00 -08:00
12
+ date: 2010-01-15 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -82,6 +82,16 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: "0"
84
84
  version:
85
+ - !ruby/object:Gem::Dependency
86
+ name: less
87
+ type: :development
88
+ version_requirement:
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
85
95
  description: Generic interface to multiple Ruby template engines
86
96
  email: r@tomayko.com
87
97
  executables: []
@@ -102,6 +112,7 @@ files:
102
112
  - test/tilt_erbtemplate_test.rb
103
113
  - test/tilt_erubistemplate_test.rb
104
114
  - test/tilt_hamltemplate_test.rb
115
+ - test/tilt_lesstemplate_test.rb
105
116
  - test/tilt_liquidtemplate_test.rb
106
117
  - test/tilt_mustachetemplate_test.rb
107
118
  - test/tilt_rdiscounttemplate_test.rb