pieces 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/pieces/compilers/route_compiler.rb +15 -1
- data/lib/pieces/compilers/style_compiler.rb +9 -6
- data/lib/pieces/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6ee4dda30033a5731985268919bbd5287513269
|
4
|
+
data.tar.gz: baa91e4fc63e49afc2cf83ce0999742fc2382372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a8af9f673d72d5582d42ebd203830b36e1eae705af39675c9997fb56fb32beb959f5c6b90c7c8badb157ac06046154a17318fa156026a77558ee3abe8bf6fec
|
7
|
+
data.tar.gz: 17c49ca65c2ce7f228a99ac3d5b7543cf179138d7e56a9166c3d1cc90ed8caebe4815230ae3ada7fdb766b939132288ba34a4a7c0282a55736d9f7704b369f7c
|
data/README.md
CHANGED
@@ -131,6 +131,14 @@ bundle exec rails s
|
|
131
131
|
|
132
132
|
And then visit [http://localhost:3000/styleguide](http://localhost:3000/styleguide)
|
133
133
|
|
134
|
+
Alternatively you can run your styleguide without rails:
|
135
|
+
|
136
|
+
```
|
137
|
+
bundle exec pieces s
|
138
|
+
```
|
139
|
+
|
140
|
+
And then visit [http://localhost:8080](http://localhost:8080)
|
141
|
+
|
134
142
|
## Create new static site
|
135
143
|
|
136
144
|
To create a new static site with pieces:
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
1
3
|
module Pieces
|
2
4
|
class RouteCompiler
|
3
5
|
attr_reader :path
|
@@ -33,7 +35,7 @@ module Pieces
|
|
33
35
|
end
|
34
36
|
|
35
37
|
def compile_piece(piece, data)
|
36
|
-
view_model =
|
38
|
+
view_model = ViewModel.new(data['_global'].merge(data))
|
37
39
|
::Tilt.new(piece_path(piece)).render(view_model) { yield_pieces(data) }
|
38
40
|
end
|
39
41
|
|
@@ -42,5 +44,17 @@ module Pieces
|
|
42
44
|
contents << compile_piece(piece, data)
|
43
45
|
end
|
44
46
|
end
|
47
|
+
|
48
|
+
class ViewModel < OpenStruct
|
49
|
+
if defined?(ActionView)
|
50
|
+
include ActionView::Context
|
51
|
+
include ActionView::Helpers
|
52
|
+
end
|
53
|
+
|
54
|
+
def initialize(*)
|
55
|
+
super
|
56
|
+
_prepare_context if defined?(ActionView)
|
57
|
+
end
|
58
|
+
end
|
45
59
|
end
|
46
60
|
end
|
@@ -8,13 +8,16 @@ module Pieces
|
|
8
8
|
|
9
9
|
def compile(files)
|
10
10
|
files.merge('compiled.css' => { contents: '', type: 'css' }).tap do |files|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
files['compiled.css'][:contents] << yield_stylesheets('app/assets/stylesheets/components')
|
12
|
+
files['compiled.css'][:contents] << yield_stylesheets('app/views')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
def yield_stylesheets(dir)
|
19
|
+
Dir["#{path}/#{dir}/**/*.{css,scss,sass,less}"].reduce('') do |contents, stylesheet|
|
20
|
+
contents << ::Tilt.new(stylesheet).render
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
data/lib/pieces/version.rb
CHANGED