serbea 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/serbea.rb +4 -0
- data/lib/serbea/rails_support.rb +13 -0
- data/lib/version.rb +1 -1
- data/serbea.gemspec +4 -2
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72bb8c66c7a574ed69bbec8995cd8a5e28fa72caf82768264b95b602ce1db815
|
4
|
+
data.tar.gz: 3cece4d891ef8100bf0a5eb51570f89bdc58566914fe6f0b514d21a3a76e2f7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b8d9d2677748d88ec34dbea4abbf65fb05253c0ccd8d1f4bcde2f9781ef9056194a6c25bfe8027dc20f906055fd7db023587aedbb944025109cc443ad9e720a
|
7
|
+
data.tar.gz: a9622d5f4a502291fd8472eb24f2f6e479f434897eec51095eb2ba668b95fd1dd438eb400274d9811eaddfbd485e523d76ce7230245f9e8d11a284170afe3725
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Serbea combines the best ideas from "brace-style" template languages such as Liq
|
|
11
11
|
* Autoescaped variables by default within the pipeline (`{{ }}`) tags. Use the `safe`/`raw` or `escape`/`h` filters to control escaping on output.
|
12
12
|
* Render directive `{%@ %}` as shortcut for rendering either string-named partials (`render "tmpl"`) or object instances (`render MyComponent.new`).
|
13
13
|
* Supports every convention of ERB and builds upon it with new features (which is why it's "awesomer!").
|
14
|
-
* Builtin frontmatter support
|
14
|
+
* Builtin frontmatter support so you can access the variables written into the top YAML within your templates. In any Rails view, including layouts, you'll have access to the `@frontmatter` ivar which is a merged `HashWithDotAccess::Hash` with data from any part of the view tree (partials, pages, layout).
|
15
15
|
* The filters accessible within Serbea templates are either helpers (where the variable gets passed as the first argument) or instance methods of the variable itself, so you can build extremely expressive pipelines that take advantage of the code you already know and love. (For example, in Rails you could write `{{ "My Link" | link_to: route_path }}`).
|
16
16
|
* The `Serbea::Pipeline.exec` method lets you pass a pipeline template in, along with an optional input value or included helpers module, and you'll get the output as a object of any type (not converted to a string like in traditional templates). For example: `Serbea::Pipeline.exec("[1,2,3] |> map: ->(i) { i * 10 }")` will return `[10, 20, 30]`.
|
17
17
|
|
data/lib/serbea.rb
CHANGED
data/lib/serbea/rails_support.rb
CHANGED
@@ -15,6 +15,19 @@ module Serbea
|
|
15
15
|
|
16
16
|
new.compile(template, source)
|
17
17
|
end
|
18
|
+
|
19
|
+
def self.initialize_frontmatter
|
20
|
+
if defined?(ApplicationHelper)
|
21
|
+
Serbea::TemplateEngine.front_matter_preamble = "self.set_page_frontmatter = local_frontmatter = YAML.load"
|
22
|
+
|
23
|
+
ApplicationHelper.define_method(:set_page_frontmatter=) do |data|
|
24
|
+
@frontmatter ||= HashWithDotAccess::Hash.new
|
25
|
+
@frontmatter.update(data)
|
26
|
+
end
|
27
|
+
|
28
|
+
ApplicationController.before_action { @frontmatter ||= HashWithDotAccess::Hash.new }
|
29
|
+
end
|
30
|
+
end
|
18
31
|
end
|
19
32
|
end
|
20
33
|
|
data/lib/version.rb
CHANGED
data/serbea.gemspec
CHANGED
@@ -16,8 +16,10 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features)/!) }
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_runtime_dependency("rake", "~> 13.0")
|
20
|
-
spec.add_runtime_dependency("erubi", "~> 1.9")
|
21
19
|
spec.add_runtime_dependency("activesupport", "~> 6.0")
|
20
|
+
spec.add_runtime_dependency("erubi", "~> 1.9")
|
21
|
+
spec.add_runtime_dependency("hash_with_dot_access", "~> 1.1")
|
22
22
|
spec.add_runtime_dependency("tilt", "~> 2.0")
|
23
|
+
|
24
|
+
spec.add_development_dependency("rake", "~> 13.0")
|
23
25
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serbea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: erubi
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: hash_with_dot_access
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: tilt
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '13.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '13.0'
|
69
83
|
description:
|
70
84
|
email: maintainers@bridgetownrb.com
|
71
85
|
executables: []
|