cft 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/cft/template.rb +38 -0
  2. metadata +2 -1
@@ -0,0 +1,38 @@
1
+ require 'tilt'
2
+
3
+ module CFT
4
+ # Tilt engine class for the CFT compiler. Depends on the `cft` gem.
5
+ #
6
+ # For more infomation see:
7
+ #
8
+ # https://github.com/sstephenson/ruby-eco
9
+ # https://github.com/sstephenson/eco
10
+ #
11
+ class Template < Tilt::Template
12
+ # Check to see if CFT is loaded
13
+ def self.engine_initialized?
14
+ defined? ::CFT
15
+ end
16
+
17
+ # Autoload eco library. If the library isn't loaded, Tilt will produce
18
+ # a thread safetly warning. If you intend to use `.eco` files, you
19
+ # should explicitly require it.
20
+ def initialize_engine
21
+ require_template_library 'cft'
22
+ end
23
+
24
+ def prepare
25
+ end
26
+
27
+ # Compile template data with CFT compiler.
28
+ #
29
+ # Returns a JS function definition String. The result should be
30
+ # assigned to a JS variable.
31
+ #
32
+ # # => "function(...) {...}"
33
+ #
34
+ def evaluate(scope, locals, &block)
35
+ CFT.compile(data)
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -68,6 +68,7 @@ extensions: []
68
68
  extra_rdoc_files: []
69
69
  files:
70
70
  - lib/cft.rb
71
+ - lib/cft/template.rb
71
72
  - LICENSE
72
73
  - README.md
73
74
  homepage: https://github.com/maccman/ruby-cft