hamljs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Andrew Timberlake
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ HAML.js template compiler for Ruby
2
+ ==================================
3
+
4
+ Will change haml.js files like:
5
+
6
+ %h1= title
7
+ %p= body
8
+
9
+ into:
10
+
11
+ HAML("%h1= title\n %p= body")
12
+
13
+
14
+ Which can then be used in sprockets
15
+
16
+ -----
17
+
18
+ © 2011 Andrew Timberlake
19
+
20
+ Released under the MIT license
@@ -0,0 +1,18 @@
1
+ module Hamljs
2
+ class Engine
3
+ def self.compile(source, options = {})
4
+ source = source.dup
5
+
6
+ escape! source
7
+
8
+ "HAML('#{source}')"
9
+ end
10
+
11
+ protected
12
+ def self.escape!(source)
13
+ source.gsub!(/\\/) { '\\\\' }
14
+ source.gsub!(/'/) { "\\'" }
15
+ source.gsub!(/\n/) { "\\n" }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ require 'tilt'
2
+ require 'engine'
3
+
4
+ module Hamljs
5
+ class SprocketsTemplate < Tilt::Template
6
+
7
+ def self.engine_initialized?
8
+ defined? Hamljs::Engine
9
+ end
10
+
11
+ def initialize_engine
12
+ end
13
+
14
+ def prepare
15
+ end
16
+
17
+ def evaluate(scope, locals, &block)
18
+ Hamljs::Engine.compile(data)
19
+ end
20
+ end
21
+ end
data/lib/hamljs.rb ADDED
@@ -0,0 +1,5 @@
1
+ if defined?(:Sprockets)
2
+ require 'hamljs/sprockets_template'
3
+
4
+ Sprockets.register_engine '.hamljs', Hamljs::SprocketsTemplate
5
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hamljs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Timberlake
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-11 00:00:00.000000000 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+ description: Compiles HAML templates for use in JST templating systems
16
+ email:
17
+ - andrew@andrewtimberlake.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - README.md
23
+ - LICENSE
24
+ - lib/hamljs/engine.rb
25
+ - lib/hamljs/sprockets_template.rb
26
+ - lib/hamljs.rb
27
+ has_rdoc: true
28
+ homepage: https://github.com/andrewtimberlake/ruby-hamljs/
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 1.6.2
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: Haml.js template compiler for Ruby
52
+ test_files: []