spiffy 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/spiffy.rb +11 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e8d76a02cdca394e2e7adf8a35c54cef6d68eb6
4
- data.tar.gz: 1301a63836cf1a65b89dacd80420ef8ff252c3fc
3
+ metadata.gz: 29eb3f44f3eab44a2df175df926f610d9a1d3e27
4
+ data.tar.gz: b9a59b2543b00c69d873a9d47642387a213a35e6
5
5
  SHA512:
6
- metadata.gz: d0f4aa045b82846c5675b86ffd201fd4f0a9b300e9e0ef292704d33aba7cca34d5a44a3bd0b56d4a9759ef6480a81b7bb9de63761366e650f18bbaef68e67187
7
- data.tar.gz: 656b11a72571699ef5f9f1411cbd083e2fd686432be735d22604a6ba7f283d6a0b527fd6401b71ca41047e3b6e538a8a94a2408ff9ef44ad52686e29f13ec160
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.13"
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 { |section| case section; when :css; css; when :body, nil; html; end }
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).render { |section| case section; when :css; css; when :body, nil; html; end }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leigh McCulloch