haml-contrib 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ # Haml Contrib
2
+
3
+ This project contains various useful extensions to the Haml template language's
4
+ Ruby implementation. Such extensions are useful enough to be distributed, but
5
+ not widely used or on-topic enough to belong in Haml proper.
6
+
7
+ This gives the Haml project a reasonable way to both demote current
8
+ functionality, such as the Textile and Maruku filters, and add new experimental
9
+ functionality that may later be added to the core.
10
+
11
+ Haml-contrib currently requires the latest alpha version of Haml.
@@ -0,0 +1 @@
1
+ Haml::Filters.register_tilt_filter "Builder", :precompiled => true
@@ -0,0 +1 @@
1
+ Haml::Filters.register_tilt_filter "Markaby", :extension => "mab"
@@ -0,0 +1 @@
1
+ Haml::Filters.register_tilt_filter "Maruku", :template_class => Tilt::MarukuTemplate
@@ -0,0 +1 @@
1
+ Haml::Filters.register_tilt_filter "Nokogiri", :precompiled => true
@@ -0,0 +1,17 @@
1
+ # A PHP Filter for Haml. This simply wraps code inside <?php ?> tags. While this
2
+ # may seem like a strange idea, some people use Haml to generate mostly static
3
+ # HTML documents that then include small amounts of PHP.
4
+ #
5
+ # This code also serves as an example of how to implement a simple filter for
6
+ # Haml.
7
+ module Haml
8
+ module Filters
9
+ module PHP
10
+ include Base
11
+
12
+ def render(text)
13
+ "<?php\n %s\n?>" % text.rstrip.gsub("\n", "\n ")
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1 @@
1
+ Haml::Filters.register_tilt_filter "Textile"
@@ -0,0 +1 @@
1
+ Haml::Filters.register_tilt_filter "Wiki"
@@ -0,0 +1 @@
1
+ Haml::Filters.register_tilt_filter "Yajl"
@@ -0,0 +1,17 @@
1
+ require "test_helper"
2
+ require "haml/filters/php"
3
+
4
+ class PHPFilterTest < Minitest::Unit::TestCase
5
+ def test_should_render
6
+ haml = ":php\n foo\n bar"
7
+ html = "<?php\n foo\n bar\n?>\n"
8
+ assert_equal html, render(haml)
9
+ end
10
+
11
+ def test_should_interpolate
12
+ scope = Object.new.instance_eval {foo = "bar"; binding}
13
+ haml = ":php\n \#{foo}"
14
+ html = "<?php\n bar\n?>\n"
15
+ assert_equal html, render(haml, :scope => scope)
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ require "bundler/setup"
2
+ require "haml"
3
+ require "minitest/autorun"
4
+
5
+ MiniTest::Unit::TestCase.send :include, Module.new {
6
+ def render(text, options = {}, &block)
7
+ scope = options.delete(:scope) || Object.new
8
+ locals = options.delete(:locals) || {}
9
+ Haml::Engine.new(text, options).to_html(scope, locals, &block)
10
+ end
11
+ }
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haml-contrib
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Norman Clarke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: haml
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0.alpha.13
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0.alpha.13
30
+ - !ruby/object:Gem::Dependency
31
+ name: minitest
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Addons for the Ruby implementation of the Haml template language.
47
+ email:
48
+ - norman@njclarke.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - lib/haml/filters/builder.rb
54
+ - lib/haml/filters/markaby.rb
55
+ - lib/haml/filters/maruku.rb
56
+ - lib/haml/filters/nokogiri.rb
57
+ - lib/haml/filters/php.rb
58
+ - lib/haml/filters/textile.rb
59
+ - lib/haml/filters/wiki.rb
60
+ - lib/haml/filters/yajl.rb
61
+ - test/php_filter_test.rb
62
+ - test/test_helper.rb
63
+ - README.md
64
+ homepage: http://haml.info/
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.24
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Addons to Haml
88
+ test_files:
89
+ - test/php_filter_test.rb
90
+ - test/test_helper.rb
91
+ has_rdoc: false