middleman-emblem 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -29,14 +29,10 @@ add `activate :emblem` to config.rb
29
29
  ## Configuration
30
30
 
31
31
  by default
32
-
33
- set :emblem_dir, "emblem_templates"
34
- set :emblem_ext, "emblem"
32
+ activate :emblem, emblem_dir: "templates", :emblem_ext, "emblem"
35
33
 
36
34
  but this can be changed in config.rb to something like
37
-
38
- set :emblem_dir, "templates_haml"
39
- set :emblem_ext, "haml"
35
+ activate :emblem, emblem_dir: "templates_haml", :emblem_ext, "haml"
40
36
 
41
37
  ## Contributing
42
38
 
@@ -1,51 +1,23 @@
1
-
2
-
1
+ require "barber-emblem"
2
+ require "middleman-emblem/sprockets-template"
3
3
 
4
4
  module Middleman
5
5
  module Emblem
6
6
  class << self
7
- def registered(app, options={})
8
- require "barber-emblem"
9
- require "#{File.dirname(__FILE__)}/sprockets-template"
10
-
11
-
7
+ @@template_root = "templates"
12
8
 
9
+ def template_root
10
+ @@template_root
11
+ end
13
12
 
13
+ def registered(app, options={})
14
+ sprocket_extension = "emblem"
14
15
  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
-
16
+ @@template_root = options[:emblem_dir] if options.has_key?(:emblem_dir)
17
+ sprocket_extension = options[:emblem_ext] if options.has_key?(:emblem_ext)
18
+ ignore "#{js_dir}/#{@@template_root}*"
19
+ ::Sprockets.register_engine ".#{sprocket_extension}", Middleman::Emblem::Template
47
20
  end
48
-
49
21
  end
50
22
  alias :included :registered
51
23
  end
@@ -3,7 +3,6 @@ require 'sprockets/engines'
3
3
  require 'barber-emblem'
4
4
  require 'barber'
5
5
 
6
-
7
6
  module Middleman
8
7
  module Emblem
9
8
  class Template < Tilt::Template
@@ -20,11 +19,34 @@ module Middleman
20
19
 
21
20
  private
22
21
 
23
-
24
22
  def template_target(scope)
25
- "Ember.TEMPLATES[#{scope.logical_path.inspect}]"
23
+ "Ember.TEMPLATES[#{template_path(scope.logical_path).inspect}]"
24
+ end
25
+
26
+ def template_path(path)
27
+ root = configuration.templates_root
28
+
29
+ if root.kind_of? Array
30
+ root.each do |root|
31
+ path.sub!(/#{Regexp.quote(root)}\//, '')
32
+ end
33
+ else
34
+ unless root.empty?
35
+ path.sub!(/#{Regexp.quote(root)}\/?/, '')
36
+ end
37
+ end
38
+
39
+ path = path.split('/')
40
+
41
+ path.join(configuration.templates_path_separator)
26
42
  end
27
43
 
44
+ def configuration
45
+ OpenStruct.new(
46
+ templates_root: Middleman::Emblem.template_root,
47
+ templates_path_separator: "/"
48
+ )
49
+ end
28
50
 
29
51
  def precompile_ember_emblem(string)
30
52
  Barber::Emblem::EmberFilePrecompiler.call(string)
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Emblem
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-emblem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-13 00:00:00.000000000 Z
12
+ date: 2013-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: barber-emblem
@@ -86,3 +86,4 @@ signing_key:
86
86
  specification_version: 3
87
87
  summary: Uses emblem butcher.
88
88
  test_files: []
89
+ has_rdoc: