sinatra-thymeleaf 0.1.2 → 0.1.3

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/sinatra/thymeleaf.rb +10 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a66de7ed8d590ef32257ead4e385c1db5cc210fc
4
- data.tar.gz: 197f992c2def8a3c044f97a1dc3aef2d32425e13
3
+ metadata.gz: ab83e5b776dfac0d7b3e188bada03b6a64b46a0c
4
+ data.tar.gz: 1c14dc2a11665bc67f781d9dc2c1ee7f5b49abeb
5
5
  SHA512:
6
- metadata.gz: d5ac23cd3ad5319c9e565543ef9512a7a6a39019b6d90a4cc6aff628f2e0c9b8767ae981e1cb12cf85b6c90a4f607d35977144af5349193a39ca5ab25b4a982a
7
- data.tar.gz: fc7070d13c3c05996473728cc6483e408e4262e81332b77c857935ee666bc9e093cad6c69424f6788126247663054577e71cf0b7b89d7ace0fb2af4e0fb1d4cd
6
+ metadata.gz: 34e953377b9b11757e5b81dafe57a457dfdf9db7c16bcba286125881fb655339c9b8455ef4c6c2da682a1f54be0abefc9188dd469a6bedb3e9f7c54b7752843e
7
+ data.tar.gz: 19019278cfae952450b32be9784635bee1b8ce42f928e679398c734bf4bdb871ebec7b49020abe6abd9415b53282dfce66d66abed028c4b790204d756c2151d7
@@ -3,18 +3,28 @@ require_relative 'tilt/thymeleaf'
3
3
  require 'i18n'
4
4
 
5
5
  module Sinatra
6
+ # we need to configure the Thymeleaf prefix and suffix for insert and replace
7
+ Thymeleaf.configuration.template.prefix = "./views/"
8
+ Thymeleaf.configuration.template.suffix = ".html"
6
9
 
7
10
  module Thymeleaf
8
11
  def thyme(template=nil, locals={}, options = {}, &block)
12
+
9
13
  options, template = template, nil if template.is_a?(Hash)
10
14
  template = lambda { block } if template.nil?
11
15
  locals[:t] = lambda { |m| I18n.t(m) }
12
16
 
17
+ # setup Sinatra flash
13
18
  locals[:flash] = {}
14
19
  unless flash.nil?
15
20
  locals[:flash] = flash
16
21
  end
17
22
 
23
+ # add warden current_user if available
24
+ unless current_user.nil?
25
+ locals[:current_user] = current_user
26
+ end
27
+
18
28
  render :html, template, options, locals
19
29
  end
20
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-thymeleaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Costea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-18 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thymeleaf