middleman-emblem 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+
5
+
6
+ # Specify your gem's dependencies in middleman-emblem.gemspec
7
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 j-mcnally
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Middleman::Emblem
2
+
3
+ A simple plugin to support emblem with Middleman
4
+
5
+ Inspired by https://github.com/GutenYe/middleman-ember-template
6
+
7
+ A great template but we wanted to add haml style support for ember templates.
8
+
9
+ Built around the Emblem JS project: https://github.com/machty/emblem.js
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'middleman-emblem'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install middleman-emblem
24
+
25
+ ## Usage
26
+
27
+ add `activate :emblem` to config.rb
28
+
29
+ ## Configuration
30
+
31
+ by default
32
+
33
+ set :emblem_dir, "emblem_templates"
34
+ set :emblem_ext, "emblem"
35
+
36
+ but this can be changed in config.rb to something like
37
+
38
+ set :emblem_dir, "templates_haml"
39
+ set :emblem_ext, "haml"
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,53 @@
1
+
2
+
3
+
4
+ module Middleman
5
+ module Emblem
6
+ class << self
7
+ def registered(app, options={})
8
+ require "barber-emblem"
9
+ require "#{File.dirname(__FILE__)}/sprockets-template"
10
+
11
+
12
+
13
+
14
+ app.after_configuration do
15
+
16
+ set :emblem_ext, "emblem" if emblem_ext.nil?
17
+ set :emblem_dir, "emblem_templates" if emblem_ext.nil?
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ ::Sprockets.register_engine ".#{emblem_ext}", Middleman::Emblem::Template
26
+ spenv = ::Sprockets::Environment.new(root)
27
+ spenv.append_path("#{source_dir}/#{emblem_dir}");
28
+
29
+ #truncate output file
30
+ File.open("#{source_dir}/app/templates.js", 'w') {|f| f.write("")}
31
+
32
+ c = 0
33
+ Dir["#{source_dir}/#{emblem_dir}/**/*.#{emblem_ext}"].each do |f|
34
+ ignore sitemap.file_to_path(f)
35
+ local_name = f.gsub("#{source_dir}/#{emblem_dir}/", "");
36
+ template = spenv[local_name].to_s
37
+ puts " \e[1m\e[33m[emblem]\e[22m compiling \e[0m #{local_name}"
38
+
39
+
40
+
41
+ basename = local_name.gsub(".#{emblem_ext}", "")
42
+ File.open("#{source_dir}/app/templates.js", 'a') {|f| f.write(template + "\r\n") }
43
+ c += 1
44
+ end
45
+ puts " \e[1m\e[33m[emblem]\e[22m compiled \e[1m\e[0m#{c} \e[22m\e[33mtemplates to \e[1m\e[0msource/app/templates.js\e[22m"
46
+
47
+ end
48
+
49
+ end
50
+ alias :included :registered
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,34 @@
1
+ require 'sprockets'
2
+ require 'sprockets/engines'
3
+ require 'barber-emblem'
4
+ require 'barber'
5
+
6
+
7
+ module Middleman
8
+ module Emblem
9
+ class Template < Tilt::Template
10
+ def self.default_mime_type
11
+ 'application/javascript'
12
+ end
13
+ def prepare; end
14
+ def evaluate(scope, locals, &block)
15
+ target = template_target(scope)
16
+ template = data
17
+ template = precompile_ember_emblem(template)
18
+ "#{target} = #{template}\n"
19
+ end
20
+
21
+ private
22
+
23
+
24
+ def template_target(scope)
25
+ "Ember.TEMPLATES[#{scope.logical_path.inspect}]"
26
+ end
27
+
28
+
29
+ def precompile_ember_emblem(string)
30
+ Barber::Emblem::EmberFilePrecompiler.call(string)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Emblem
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "middleman-emblem/version"
2
+
3
+
4
+ ::Middleman::Extensions.register(:emblem) do
5
+ require "middleman-emblem/extension"
6
+ ::Middleman::Emblem
7
+ end
@@ -0,0 +1,2 @@
1
+ require "middleman-emblem"
2
+ require "middleman-emblem/sprockets/template"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'middleman-emblem/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "middleman-emblem"
8
+ gem.version = Middleman::Emblem::VERSION
9
+ gem.authors = ["j-mcnally"]
10
+ gem.email = ["justin@kohactive.com"]
11
+ gem.description = "Emblem support for middleman"
12
+ gem.summary = "Uses emblem butcher."
13
+ gem.homepage = "https://github.com/j-mcnally/middleman-emblem"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_runtime_dependency("barber-emblem", ["~> 0.1.0"])
20
+ gem.add_runtime_dependency("emblem-source")
21
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-emblem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - j-mcnally
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: barber-emblem
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.0
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: 0.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: emblem-source
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
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: Emblem support for middleman
47
+ email:
48
+ - justin@kohactive.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lib/middleman-emblem.rb
59
+ - lib/middleman-emblem/extension.rb
60
+ - lib/middleman-emblem/sprockets-template.rb
61
+ - lib/middleman-emblem/version.rb
62
+ - lib/middleman_extension.rb
63
+ - middleman-emblem.gemspec
64
+ homepage: https://github.com/j-mcnally/middleman-emblem
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.25
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Uses emblem butcher.
88
+ test_files: []