yass 0.2.1 → 0.4.0
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.
- checksums.yaml +4 -4
- data/README.md +21 -4
- data/lib/yass/config.rb +1 -0
- data/lib/yass/liquid_tags.rb +12 -9
- data/lib/yass/source.rb +2 -1
- data/lib/yass/version.rb +1 -1
- metadata +2 -2
- /data/site-template/site/{index.default.html.liquid → index.html.liquid} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d520abe308c57950c7215ff67f420b807a04877c2c871e561fede4eff273d93a
|
4
|
+
data.tar.gz: 10d65ec2011a5f8ba550d3781fec148cb0db646ccf33ae465abd81bbbeb1d0a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e888b46f195cfcde35f56480555b07eaa150b8ad2d64f37fc81ceb67589cbe856d2b8acac7169b6bf8d42e5abc45b16246b7890986c9ad50aaba12406e841a71
|
7
|
+
data.tar.gz: a25ceff7ecc103ef8106da4c19fb4dfbba78d523384c6bbe2f5a20b5f5189a791dd7ec69dbc900d765e5ea0a5c432b169b22677304fc973df550057f1d70d8ca
|
data/README.md
CHANGED
@@ -52,8 +52,6 @@ yass watch
|
|
52
52
|
|
53
53
|
Layouts live in `layouts/` and will be applied to files with matching names. The `content` variable contains the data to render in the layout.
|
54
54
|
|
55
|
-
*layouts/page.html.liquid*
|
56
|
-
|
57
55
|
```html
|
58
56
|
<!DOCTYPE html>
|
59
57
|
<html lang="en">
|
@@ -64,9 +62,18 @@ Layouts live in `layouts/` and will be applied to files with matching names. The
|
|
64
62
|
</html>
|
65
63
|
```
|
66
64
|
|
67
|
-
|
65
|
+
If the above layout is named *page.html.liquid*, it will match any file named `*.page.html*`. Examples:
|
66
|
+
|
67
|
+
* `foo.page.html`
|
68
|
+
* `foo.page.html.*`
|
69
|
+
* `foo.page.md` (because *.md* converts to *.html*)
|
70
|
+
* `foo.page.md.*`
|
71
|
+
|
72
|
+
The name of the layout (e.g. `page`) is removed from the final filename, resulting in `foo.html`.
|
68
73
|
|
69
|
-
|
74
|
+
### Default layouts
|
75
|
+
|
76
|
+
If you create a layout named `default.<ext>.liquid`, Yass will apply it to any `.<ext>` files without layouts. For example, a layout named `default.html.liquid` will match `foo.html` or `foo.not-a-layout.md.liquid`.
|
70
77
|
|
71
78
|
## Templates
|
72
79
|
|
@@ -132,6 +139,16 @@ puts "Yass!"
|
|
132
139
|
|
133
140
|
Hightlight.js CSS and JS files with common languages are included by default with `yass init`. [Download](https://highlightjs.org/download) your own versions if you want different languages or themes.
|
134
141
|
|
142
|
+
### render_content
|
143
|
+
|
144
|
+
Renders a template, passing the block as a variable named `content`.
|
145
|
+
|
146
|
+
```html
|
147
|
+
{% render_content "my_template", other_var: "other var" %}
|
148
|
+
<p>This will be passed to "my_template" as "content"</p>
|
149
|
+
{% endrender_content %}
|
150
|
+
```
|
151
|
+
|
135
152
|
## Legal
|
136
153
|
|
137
154
|
MIT License. See LICENSE for details.
|
data/lib/yass/config.rb
CHANGED
@@ -31,6 +31,7 @@ module Yass
|
|
31
31
|
env.file_system = Liquid::LocalFileSystem.new(template_dir.to_s, "%s.liquid")
|
32
32
|
env.register_filter LiquidFilters
|
33
33
|
env.register_tag 'highlight', LiquidTags::Highlight
|
34
|
+
env.register_tag 'render_content', LiquidTags::RenderContent
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
data/lib/yass/liquid_tags.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
module Yass
|
2
2
|
module LiquidTags
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
# Works like `render`, but passes the block content to the template as a variable named `content`
|
4
|
+
class RenderContent < Liquid::Block
|
5
|
+
def render(context)
|
6
|
+
context.stack({}) do
|
7
|
+
context["block_content"] = super
|
8
|
+
r = Liquid::Render.parse("render", "#{@markup}, content: block_content", nil, @parse_context)
|
9
|
+
r.render_tag(context, +"")
|
10
|
+
end
|
9
11
|
end
|
12
|
+
end
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
+
# Wraps the block content in HTML for Highlight.js
|
15
|
+
class Highlight < Liquid::Block
|
16
|
+
def render(_context) = %(<pre><code class="language-#{@markup.strip}">#{super}</code></pre>)
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
data/lib/yass/source.rb
CHANGED
@@ -31,10 +31,11 @@ module Yass
|
|
31
31
|
return name, nil if exts.nil?
|
32
32
|
|
33
33
|
exts = exts.split(".").map { |x| EXT_CONVERSIONS[x] || x } - %w[liquid]
|
34
|
-
return "#{name}.#{exts
|
34
|
+
return "#{name}.#{exts[0]}", config.layout_cache["default.#{exts[0]}"] if exts.size == 1
|
35
35
|
|
36
36
|
layout = config.layout_cache["#{exts[-2..].join(".")}"]
|
37
37
|
exts.delete_at(-2) if layout
|
38
|
+
layout ||= config.layout_cache["default.#{exts[-1]}"]
|
38
39
|
|
39
40
|
return "#{name}.#{exts.join "."}", layout
|
40
41
|
end
|
data/lib/yass/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
@@ -75,7 +75,7 @@ files:
|
|
75
75
|
- site-template/layouts/default.html.liquid
|
76
76
|
- site-template/site/assets/highlight-default.css
|
77
77
|
- site-template/site/assets/highlight.min.js
|
78
|
-
- site-template/site/index.
|
78
|
+
- site-template/site/index.html.liquid
|
79
79
|
- site-template/templates/css_links.liquid
|
80
80
|
- site-template/templates/js_scripts.liquid
|
81
81
|
homepage: https://github.com/jhollinger/yass/
|
File without changes
|