spiffy 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spiffy.rb +11 -3
- 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: 29eb3f44f3eab44a2df175df926f610d9a1d3e27
|
4
|
+
data.tar.gz: b9a59b2543b00c69d873a9d47642387a213a35e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce8ba81172094b028aea0bfcaa3357264188986ef45ab0c0194c26b0df310f2cd7f7d4fb6c5287b7bc8fd6123aed1aaccc590330fd49518070da0f7f79df9b7f
|
7
|
+
data.tar.gz: 343d2365cf9ec465b210e18c2d891476d91ea505c1c18929484c322df20e28769b05d9fd96a873b16f0ef44f584e8415860d132d7645b7f414c86daf0c5392c9
|
data/lib/spiffy.rb
CHANGED
@@ -3,7 +3,7 @@ require "haml"
|
|
3
3
|
require "pdfkit"
|
4
4
|
|
5
5
|
module Spiffy
|
6
|
-
VERSION = "0.0.
|
6
|
+
VERSION = "0.0.14"
|
7
7
|
|
8
8
|
def self.markup_to_html(markup_file, css_file: nil, template_file: nil, pdf: false)
|
9
9
|
markup_file_ext = File.extname(markup_file)
|
@@ -19,11 +19,19 @@ module Spiffy
|
|
19
19
|
if template_file
|
20
20
|
template_ext = File.extname(template_file)
|
21
21
|
template = File.open(template_file, "r:UTF-8", &:read)
|
22
|
+
local_variables = {
|
23
|
+
file: markup_file
|
24
|
+
}
|
22
25
|
html = case template_ext
|
23
26
|
when ".erb"
|
24
|
-
ERB.new(template).result
|
27
|
+
ERB.new(template).result do |section|
|
28
|
+
case section; when :css; css; when :body, nil; html; end
|
29
|
+
end
|
25
30
|
when ".haml"
|
26
|
-
Haml::Engine.new(template)
|
31
|
+
engine = Haml::Engine.new(template)
|
32
|
+
engine.render(Object.new, local_variables) do |section|
|
33
|
+
case section; when :css; css; when :body, nil; html; end
|
34
|
+
end
|
27
35
|
else
|
28
36
|
raise "Template file #{template_file} unsupported. Only .erb or .haml are supported."
|
29
37
|
end
|