pieces 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pieces/builder.rb +1 -0
- data/lib/pieces/compilers/route_compiler.rb +1 -1
- data/lib/pieces/compilers/style_compiler.rb +1 -1
- data/lib/pieces/generator.rb +23 -2
- data/lib/pieces/tilt/css.rb +8 -0
- data/lib/pieces/tilt/mustache.rb +30 -0
- data/lib/pieces/tilt_extension.rb +4 -6
- data/lib/pieces/version.rb +1 -1
- data/lib/pieces.rb +0 -1
- metadata +3 -3
- data/lib/tilt/css.rb +0 -6
- data/lib/tilt/mustache.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf95f21e65d0bf4fd7ca923670baf2a893c5d14d
|
4
|
+
data.tar.gz: 8d0e716fa17ee6ac4fb54a605fbb9114fdca7c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a672697f08f2f7f3aa9c32f8741452058b346902175c1889f8142862efa0da12268b0a1908a4c0e53edae3be9659d1b4c1f0c0f4e6b76ed93a3f5a92a62f2835
|
7
|
+
data.tar.gz: db08a20f9635229d07baea336469dd3fc04c6279c5f48121fe8a3ec28b0d3efb16c7bb6f11b3fb1d3a38155f83f210d65ed1cb09aeb0b88ffd68ae851b960136
|
data/lib/pieces/builder.rb
CHANGED
@@ -34,7 +34,7 @@ module Pieces
|
|
34
34
|
|
35
35
|
def compile_piece(piece, data)
|
36
36
|
view_model = OpenStruct.new(data['_global'].merge(data))
|
37
|
-
Tilt.new(piece_path(piece)).render(view_model) { yield_pieces(data) }
|
37
|
+
::Tilt.new(piece_path(piece)).render(view_model) { yield_pieces(data) }
|
38
38
|
end
|
39
39
|
|
40
40
|
def yield_pieces(data)
|
@@ -9,7 +9,7 @@ module Pieces
|
|
9
9
|
def compile(files)
|
10
10
|
files.merge('compiled.css' => { contents: '', type: 'css' }).tap do |files|
|
11
11
|
Dir["#{path}/app/views/*/*.{css,scss,sass,less}"].each do |file|
|
12
|
-
files['compiled.css'][:contents] << Tilt.new(file).render
|
12
|
+
files['compiled.css'][:contents] << ::Tilt.new(file).render
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/pieces/generator.rb
CHANGED
@@ -6,8 +6,29 @@ module Pieces
|
|
6
6
|
path = config[:path] || Dir.pwd
|
7
7
|
FileUtils.mkdir_p(path)
|
8
8
|
|
9
|
-
Dir
|
10
|
-
FileUtils.
|
9
|
+
if Dir.exist?("#{path}/app/views")
|
10
|
+
FileUtils.mkdir_p("#{path}/app/views/application")
|
11
|
+
FileUtils.mkdir_p("#{path}/app/views/layouts")
|
12
|
+
|
13
|
+
unless File.exist?("#{path}/app/views/layouts/pieces.html.erb")
|
14
|
+
FileUtils.cp("#{example_path}/app/views/layouts/pieces.html.erb", "#{path}/app/views/layouts")
|
15
|
+
end
|
16
|
+
|
17
|
+
unless File.exist?("#{path}/app/views/application/header.html.erb")
|
18
|
+
FileUtils.cp("#{example_path}/app/views/application/header.html.erb", "#{path}/app/views/application")
|
19
|
+
end
|
20
|
+
|
21
|
+
unless File.exist?("#{path}/app/views/application/footer.html.erb")
|
22
|
+
FileUtils.cp("#{example_path}/app/views/application/footer.html.erb", "#{path}/app/views/application")
|
23
|
+
end
|
24
|
+
else
|
25
|
+
FileUtils.mkdir_p("#{path}/app/")
|
26
|
+
FileUtils.cp_r("#{example_path}/app/views", "#{path}/app/views")
|
27
|
+
end
|
28
|
+
|
29
|
+
unless File.exist?("#{path}/config/pieces.yml")
|
30
|
+
FileUtils.mkdir_p("#{path}/config")
|
31
|
+
FileUtils.cp("#{example_path}/config/pieces.yml", "#{path}/config/pieces.yml")
|
11
32
|
end
|
12
33
|
|
13
34
|
unless File.exist?("#{path}/Gemfile")
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Pieces
|
2
|
+
module Tilt
|
3
|
+
class MustacheTemplate < ::Tilt::Template
|
4
|
+
def initialize_engine; end
|
5
|
+
|
6
|
+
def prepare; end
|
7
|
+
|
8
|
+
def evaluate(scope, locals, &block)
|
9
|
+
require 'mustache'
|
10
|
+
Mustache.render(data, with_block(view_model(scope, locals), &block))
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def view_model(scope, locals)
|
16
|
+
if scope.is_a?(Hash)
|
17
|
+
locals.merge(scope)
|
18
|
+
elsif scope.respond_to?(:to_h)
|
19
|
+
locals.merge(scope.to_h)
|
20
|
+
else
|
21
|
+
locals
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def with_block(view_model, &block)
|
26
|
+
view_model.merge(:yield => block.nil? ? '' : block.call)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -4,13 +4,11 @@ module Tilt
|
|
4
4
|
if respond_to?(:register_lazy)
|
5
5
|
register_lazy :MustacheTemplate, 'tilt/mustache', 'mustache', 'ms'
|
6
6
|
register_lazy :CssTemplate, 'tilt/css', 'css'
|
7
|
-
elsif defined?(Rails)
|
8
|
-
# Register these yourself
|
9
7
|
else # support tilt v1
|
10
|
-
require 'tilt/mustache'
|
11
|
-
register MustacheTemplate, 'mustache', 'ms'
|
8
|
+
require 'pieces/tilt/mustache'
|
9
|
+
register Tilt::MustacheTemplate, 'mustache', 'ms'
|
12
10
|
|
13
|
-
require 'tilt/css'
|
14
|
-
register CssTemplate, 'css'
|
11
|
+
require 'pieces/tilt/css'
|
12
|
+
register Tilt::CssTemplate, 'css'
|
15
13
|
end
|
16
14
|
end
|
data/lib/pieces/version.rb
CHANGED
data/lib/pieces.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pieces
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Morton
|
@@ -238,10 +238,10 @@ files:
|
|
238
238
|
- lib/pieces/listener.rb
|
239
239
|
- lib/pieces/rails.rb
|
240
240
|
- lib/pieces/server.rb
|
241
|
+
- lib/pieces/tilt/css.rb
|
242
|
+
- lib/pieces/tilt/mustache.rb
|
241
243
|
- lib/pieces/tilt_extension.rb
|
242
244
|
- lib/pieces/version.rb
|
243
|
-
- lib/tilt/css.rb
|
244
|
-
- lib/tilt/mustache.rb
|
245
245
|
- pieces.gemspec
|
246
246
|
homepage: https://github.com/drpheltright/pieces
|
247
247
|
licenses:
|
data/lib/tilt/css.rb
DELETED
data/lib/tilt/mustache.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'mustache'
|
2
|
-
|
3
|
-
module Tilt
|
4
|
-
class MustacheTemplate < Template
|
5
|
-
def initialize_engine; end
|
6
|
-
|
7
|
-
def prepare; end
|
8
|
-
|
9
|
-
def evaluate(scope, locals, &block)
|
10
|
-
Mustache.render(data, with_block(view_model(scope, locals), &block))
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def view_model(scope, locals)
|
16
|
-
if scope.is_a?(Hash)
|
17
|
-
locals.merge(scope)
|
18
|
-
elsif scope.respond_to?(:to_h)
|
19
|
-
locals.merge(scope.to_h)
|
20
|
-
else
|
21
|
-
locals
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def with_block(view_model, &block)
|
26
|
-
view_model.merge(:yield => block.nil? ? '' : block.call)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|