slim 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,9 +9,9 @@ Slim is a fast, lightweight templating engine with support for __Rails 3__. It h
9
9
 
10
10
  Slim's core syntax is guided by one thought: "What's the minimum required to make this work".
11
11
 
12
- As more people have contributed to Slim, there have been ___optional___ syntax additions influenced from their use of [Haml](http://github.com/nex3/haml) and [Jade](http://github.com/visionmedia/jade). The Slim team is open to these optional additions because we know beauty is in the eye of the beholder.
12
+ As more people have contributed to Slim, there have been ___optional___ syntax additions influenced from their use of [Haml](https://github.com/nex3/haml) and [Jade](https://github.com/visionmedia/jade). The Slim team is open to these optional additions because we know beauty is in the eye of the beholder.
13
13
 
14
- Slim uses [Temple](http://github.com/judofyr/temple) for parsing/compilation and is also integrated into [Tilt](http://github.com/rtomayko/tilt), so it can be used together with [Sinatra](http://github.com/sinatra/sinatra) or plain [Rack](http://github.com/rack/rack).
14
+ Slim uses [Temple](https://github.com/judofyr/temple) for parsing/compilation and is also integrated into [Tilt](https://github.com/rtomayko/tilt), so it can be used together with [Sinatra](https://github.com/sinatra/sinatra) or plain [Rack](https://github.com/rack/rack).
15
15
 
16
16
  ## Why?
17
17
 
@@ -41,7 +41,11 @@ If you want to use the Slim template directly, you can use the Tilt interface:
41
41
 
42
42
  ## Syntax Highlighters
43
43
 
44
- Syntax highlight support for __Vim__ (very beta) and __Emacs__ are included in the `extra` folder. There is also a [Textmate bundle](http://github.com/fredwu/ruby-slim-textmate-bundle).
44
+ Syntax highlight support for __Vim__ (very beta) and __Emacs__ are included in the `extra` folder. There is also a [Textmate bundle](https://github.com/fredwu/ruby-slim-textmate-bundle).
45
+
46
+ ## Template Converters
47
+
48
+ For Haml, there is a [Haml2Slim converter](https://github.com/fredwu/haml2slim). Please check out the [issue tracker](https://github.com/stonean/slim/issues) to see the status of the varies converters.
45
49
 
46
50
  ## The syntax
47
51
 
@@ -262,35 +266,58 @@ Here's a quick example to demonstrate what a Slim template looks like:
262
266
 
263
267
  <body><p></p></body>
264
268
 
269
+ ### Validate Slim syntax
270
+
271
+ There are two helpers you could use to validate your Slim syntax:
272
+
273
+ Slim::Validator.valid?(source) # -> true or false
274
+ Slim::Validator.validate!(source) # -> true or exception
275
+
265
276
  ## Benchmarks
266
277
 
267
- # OS X 10.6 + Ruby 1.9.2
268
-
269
- user system total real
270
- erb 2.200000 0.020000 2.220000 ( 2.259262)
271
- erubis 1.870000 0.010000 1.880000 ( 1.895547)
272
- fast erubis 1.870000 0.010000 1.880000 ( 1.887996)
273
- slim 10.380000 0.080000 10.460000 ( 10.543296)
274
- haml 16.250000 0.070000 16.320000 ( 16.376137)
275
- haml ugly 15.700000 0.080000 15.780000 ( 15.869233)
276
- erb (compiled) 0.820000 0.010000 0.830000 ( 0.821538)
277
- erubis (compiled) 0.680000 0.000000 0.680000 ( 0.680444)
278
- fast erubis (compiled) 0.600000 0.010000 0.610000 ( 0.605370)
279
- slim (compiled) 0.180000 0.000000 0.180000 ( 0.182536)
280
- haml (compiled) 1.800000 0.020000 1.820000 ( 1.863224)
281
- haml ugly (compiled) 1.560000 0.020000 1.580000 ( 1.602106)
282
- erb (cached) 0.120000 0.000000 0.120000 ( 0.127988)
283
- erubis (cached) 0.110000 0.000000 0.110000 ( 0.115064)
284
- fast erubis (cached) 0.120000 0.010000 0.130000 ( 0.122645)
285
- slim (cached) 0.140000 0.000000 0.140000 ( 0.134598)
286
- haml (cached) 0.660000 0.000000 0.660000 ( 0.661025)
287
- haml ugly (cached) 0.590000 0.010000 0.600000 ( 0.602522)
278
+ # OS X 10.6 + Ruby 1.9.2, 1000 iterations
279
+
280
+ user system total real
281
+ (1) erb 0.420000 0.000000 0.420000 ( 0.429334)
282
+ (1) erubis 0.350000 0.000000 0.350000 ( 0.356078)
283
+ (1) fast erubis 0.350000 0.000000 0.350000 ( 0.355976)
284
+ (1) slim 3.300000 0.010000 3.310000 ( 3.340637)
285
+ (1) haml 2.950000 0.000000 2.950000 ( 2.970671)
286
+ (1) haml ugly 2.840000 0.010000 2.850000 ( 2.856405)
287
+ (2) erb 0.150000 0.000000 0.150000 ( 0.151098)
288
+ (2) erubis 0.130000 0.000000 0.130000 ( 0.130713)
289
+ (2) fast erubis 0.100000 0.000000 0.100000 ( 0.112199)
290
+ (2) slim 0.030000 0.000000 0.030000 ( 0.027752)
291
+ (2) haml 0.320000 0.000000 0.320000 ( 0.332581)
292
+ (2) haml ugly 0.280000 0.000000 0.280000 ( 0.305250)
293
+ (3) erb 0.010000 0.000000 0.010000 ( 0.014402)
294
+ (3) erubis 0.010000 0.000000 0.010000 ( 0.015365)
295
+ (3) fast erubis 0.010000 0.000000 0.010000 ( 0.012789)
296
+ (3) slim 0.010000 0.000000 0.010000 ( 0.015583)
297
+ (3) haml 0.120000 0.000000 0.120000 ( 0.120017)
298
+ (3) haml ugly 0.100000 0.010000 0.110000 ( 0.117665)
299
+
300
+ 1. Uncached benchmark. Template is parsed every time.
301
+ Activate this benchmark with slow=1.
302
+
303
+ 2. Cached benchmark. Template is parsed before the benchmark.
304
+ The ruby code generated by the template engine might be evaluated every time.
305
+ This benchmark uses the standard API of the template engine.
306
+
307
+ 3. Compiled benchmark. Template is parsed before the benchmark and
308
+ generated ruby code is compiled into a method.
309
+ This is the fastest evaluation strategy because it benchmarks
310
+ pure execution speed of the generated ruby code.
311
+
312
+ ## License
313
+
314
+ This project is released under the MIT license.
288
315
 
289
316
  ## Authors
290
317
 
291
- * [Andrew Stone](http://github.com/stonean)
292
- * [Fred Wu](http://github.com/fredwu)
293
- * [Daniel Mendler](http://github.com/minad)
318
+ * [Andrew Stone](https://github.com/stonean)
319
+ * [Fred Wu](https://github.com/fredwu)
320
+ * [Daniel Mendler](https://github.com/minad)
294
321
 
295
322
  ## Discuss
296
323
 
@@ -298,6 +325,6 @@ Here's a quick example to demonstrate what a Slim template looks like:
298
325
 
299
326
  ## Slim related projects
300
327
 
301
- * [Textmate bundle](http://github.com/fredwu/ruby-slim-textmate-bundle)
302
- * [Rails 3 Generators](http://github.com/leogalmeida/slim-rails)
303
- * [Slim for Clojure](http://github.com/chaslemley/slim.clj)
328
+ * [Textmate bundle](https://github.com/fredwu/ruby-slim-textmate-bundle)
329
+ * [Rails 3 Generators](https://github.com/leogalmeida/slim-rails)
330
+ * [Slim for Clojure](https://github.com/chaslemley/slim.clj)
File without changes
@@ -12,3 +12,4 @@ require 'slim/engine'
12
12
  require 'slim/template'
13
13
  require 'slim/version'
14
14
  require 'slim/wrapper'
15
+ require 'slim/validator'
@@ -0,0 +1,16 @@
1
+ module Slim
2
+ class Validator
3
+ class << self
4
+ def validate!(source)
5
+ Slim::Engine.new.compile(source.to_s)
6
+ true
7
+ rescue Exception => ex
8
+ ex
9
+ end
10
+
11
+ def valid?(source)
12
+ validate!(source) === true
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Slim
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 0
9
- version: 0.8.0
8
+ - 1
9
+ version: 0.8.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andrew Stone
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-29 00:00:00 -05:00
19
+ date: 2010-12-17 00:00:00 +11:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -147,14 +147,14 @@ email:
147
147
  - ifredwu@gmail.com
148
148
  - mail@daniel-mendler.de
149
149
  executables:
150
- - slim
150
+ - slimrb
151
151
  extensions: []
152
152
 
153
153
  extra_rdoc_files:
154
154
  - README.md
155
155
  files:
156
156
  - README.md
157
- - bin/slim
157
+ - bin/slimrb
158
158
  - lib/slim.rb
159
159
  - lib/slim/command.rb
160
160
  - lib/slim/compiler.rb
@@ -167,6 +167,7 @@ files:
167
167
  - lib/slim/rails.rb
168
168
  - lib/slim/sections.rb
169
169
  - lib/slim/template.rb
170
+ - lib/slim/validator.rb
170
171
  - lib/slim/version.rb
171
172
  - lib/slim/wrapper.rb
172
173
  has_rdoc: true