liquidum 1.4.2 → 1.4.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.
- checksums.yaml +4 -4
- data/.shipkit.yml +1 -1
- data/README.md +11 -0
- data/app/controllers/liquidum/tags_controller.rb +13 -0
- data/config/locales/en.yml +21 -0
- data/config/locales/nl.yml +21 -0
- data/config/routes.rb +1 -0
- data/lib/liquidum/tags.rb +51 -0
- data/lib/liquidum/version.rb +1 -1
- data/lib/liquidum.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96d0ead154fefe58f08b4f87c9981cf141ae8b149a740bb02b30550fca32137c
|
|
4
|
+
data.tar.gz: 2bfceaf7029f7a3d9675424197b90e8f54ce14820a0eecda3ef58a3d72c3826a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 199d3b0735522241c505b79e095b257bf5013f417d4daa947ae94490d35dcf4adf5d6c852c1329225c29d8e4dbe29e58a2b5fdd0e4449451cd4397cd307cc521
|
|
7
|
+
data.tar.gz: bdd601cb35ccee0d7cba791ddc2b7201399074cbb53e45564f7469442ea158c0f8f9f9cdc1cbc9fc37430a8baa2c643bb70a0c0c624083f4263aa2b6e86f635a
|
data/.shipkit.yml
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
---
|
|
2
|
-
previous_version: 1.4.
|
|
2
|
+
previous_version: 1.4.2
|
data/README.md
CHANGED
|
@@ -100,6 +100,17 @@ An argument's kind is `property`, `value` (of the property before it),
|
|
|
100
100
|
`format` (a date's), `key` (a translation's) or `any`. An app describes its own
|
|
101
101
|
filters with `Liquidum::Filters.describe :money, arguments: [[:currency]]`, and
|
|
102
102
|
labels them as `liquidum.filters.<name>`.
|
|
103
|
+
|
|
104
|
+
And for what can follow `{%`, the tags, each with how it's written and whether
|
|
105
|
+
it's a block, which an editor writes with its closing tag:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
GET /liquidum/tags
|
|
109
|
+
{"tags": [{"name": "if", "label": "Only when a condition holds", "syntax": "if condition", "block": true}, …]}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
An app describes its own with `Liquidum::Tags.describe :signature_field, syntax: "signature_field kind signer"`,
|
|
113
|
+
labelled as `liquidum.tags.<name>`.
|
|
103
114
|
The endpoint only describes variables and never reads a record. Its
|
|
104
115
|
controllers inherit from `::ApplicationController`; to choose another one:
|
|
105
116
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_dependency "liquidum/application_controller"
|
|
2
|
+
|
|
3
|
+
module Liquidum
|
|
4
|
+
# The tags a template can use, for an editor's completion after {%
|
|
5
|
+
# (Liquidum::Tags), labelled in the request's locale:
|
|
6
|
+
#
|
|
7
|
+
# GET /liquidum/tags → {tags: [{name, label, syntax, block}]}
|
|
8
|
+
class TagsController < ApplicationController
|
|
9
|
+
def index
|
|
10
|
+
render json: {tags: Tags.all}
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/config/locales/en.yml
CHANGED
|
@@ -27,6 +27,27 @@ en:
|
|
|
27
27
|
context:
|
|
28
28
|
not_a_json_object: 'must be a JSON object, like {"name": "value"}'
|
|
29
29
|
liquidum:
|
|
30
|
+
tags:
|
|
31
|
+
assign: "Sets a variable"
|
|
32
|
+
attach: "Attaches a file"
|
|
33
|
+
break: "Stops the loop"
|
|
34
|
+
capture: "Sets a variable to its text"
|
|
35
|
+
case: "One of several, by a variable's value"
|
|
36
|
+
comment: "Not shown"
|
|
37
|
+
continue: "Goes on with the loop's next item"
|
|
38
|
+
cycle: "Each time the next of its values"
|
|
39
|
+
decrement: "Counts down"
|
|
40
|
+
echo: "Shows a value"
|
|
41
|
+
for: "For each item"
|
|
42
|
+
helper: "A helper's output"
|
|
43
|
+
if: "Only when a condition holds"
|
|
44
|
+
ifchanged: "Only when it changed"
|
|
45
|
+
include: "Another template, sharing variables"
|
|
46
|
+
increment: "Counts up"
|
|
47
|
+
raw: "Liquid shown as it is"
|
|
48
|
+
render: "Another template"
|
|
49
|
+
tablerow: "A table row for each item"
|
|
50
|
+
unless: "Only when a condition doesn't hold"
|
|
30
51
|
filters:
|
|
31
52
|
abs: "Absolute value"
|
|
32
53
|
append: "Text added after it"
|
data/config/locales/nl.yml
CHANGED
|
@@ -27,6 +27,27 @@ nl:
|
|
|
27
27
|
context:
|
|
28
28
|
not_a_json_object: 'moet een JSON-object zijn, zoals {"naam": "waarde"}'
|
|
29
29
|
liquidum:
|
|
30
|
+
tags:
|
|
31
|
+
assign: "Zet een variabele"
|
|
32
|
+
attach: "Voegt een bestand toe"
|
|
33
|
+
break: "Stopt de lus"
|
|
34
|
+
capture: "Zet een variabele op de tekst erin"
|
|
35
|
+
case: "Een van meerdere, naar de waarde van een variabele"
|
|
36
|
+
comment: "Niet getoond"
|
|
37
|
+
continue: "Gaat door met het volgende item"
|
|
38
|
+
cycle: "Telkens de volgende van de waarden"
|
|
39
|
+
decrement: "Telt af"
|
|
40
|
+
echo: "Toont een waarde"
|
|
41
|
+
for: "Voor elk item"
|
|
42
|
+
helper: "De uitvoer van een helper"
|
|
43
|
+
if: "Alleen als een voorwaarde geldt"
|
|
44
|
+
ifchanged: "Alleen als het veranderde"
|
|
45
|
+
include: "Een ander sjabloon, met dezelfde variabelen"
|
|
46
|
+
increment: "Telt op"
|
|
47
|
+
raw: "Liquid getoond zoals het is"
|
|
48
|
+
render: "Een ander sjabloon"
|
|
49
|
+
tablerow: "Een tabelrij voor elk item"
|
|
50
|
+
unless: "Alleen als een voorwaarde niet geldt"
|
|
30
51
|
filters:
|
|
31
52
|
abs: "Absolute waarde"
|
|
32
53
|
append: "Tekst erachter"
|
data/config/routes.rb
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Liquidum
|
|
4
|
+
# The tags a template can use, for an editor's completion after {%: those
|
|
5
|
+
# Liquid has registered (its own, Liquidum's and the host's), each with how
|
|
6
|
+
# it's written and whether it's a block, which the editor writes with its
|
|
7
|
+
# closing tag ({% if … %}{% endif %}).
|
|
8
|
+
#
|
|
9
|
+
# Liquidum::Tags.all
|
|
10
|
+
# # => [{name: "if", label: "Only when a condition holds", syntax: "if condition", block: true}, …]
|
|
11
|
+
#
|
|
12
|
+
# The tags inside a block (elsif, else, when) are Liquid's syntax, which the
|
|
13
|
+
# editor knows. Labels are liquidum.tags.<name>, in the current locale; a
|
|
14
|
+
# host describes its own tags the same way:
|
|
15
|
+
#
|
|
16
|
+
# Liquidum::Tags.describe :signature_field, syntax: "signature_field kind signer"
|
|
17
|
+
module Tags
|
|
18
|
+
SYNTAX = {}
|
|
19
|
+
# Not for writing by hand: an inline comment, documentation
|
|
20
|
+
HIDDEN = %w[# doc].freeze
|
|
21
|
+
|
|
22
|
+
module_function
|
|
23
|
+
|
|
24
|
+
def describe(name, syntax:)
|
|
25
|
+
SYNTAX[name.to_s] = syntax
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def all
|
|
29
|
+
Liquid::Environment.default.tags.to_h.filter_map do |name, tag|
|
|
30
|
+
next if HIDDEN.include?(name)
|
|
31
|
+
|
|
32
|
+
tag = tag.safe_constantize if tag.is_a?(String)
|
|
33
|
+
{
|
|
34
|
+
name: name,
|
|
35
|
+
label: I18n.t(name, scope: "liquidum.tags", default: name.humanize),
|
|
36
|
+
syntax: SYNTAX.fetch(name, name),
|
|
37
|
+
block: !!(tag && tag < Liquid::Block)
|
|
38
|
+
}
|
|
39
|
+
end.sort_by { |tag| tag[:name] }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
"assign" => "assign variable = value", "capture" => "capture variable", "case" => "case variable",
|
|
44
|
+
"cycle" => "cycle value, value", "decrement" => "decrement variable", "echo" => "echo value",
|
|
45
|
+
"for" => "for item in collection", "if" => "if condition", "ifchanged" => "ifchanged",
|
|
46
|
+
"include" => "include 'name'", "increment" => "increment variable", "render" => "render 'name'",
|
|
47
|
+
"tablerow" => "tablerow item in collection", "unless" => "unless condition", "attach" => "attach value",
|
|
48
|
+
"helper" => "helper name"
|
|
49
|
+
}.each { |name, syntax| describe(name, syntax: syntax) }
|
|
50
|
+
end
|
|
51
|
+
end
|
data/lib/liquidum/version.rb
CHANGED
data/lib/liquidum.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: liquidum
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tom de Grunt
|
|
@@ -294,6 +294,7 @@ files:
|
|
|
294
294
|
- app/controllers/liquidum/conversions_controller.rb
|
|
295
295
|
- app/controllers/liquidum/filters_controller.rb
|
|
296
296
|
- app/controllers/liquidum/sandbox_controller.rb
|
|
297
|
+
- app/controllers/liquidum/tags_controller.rb
|
|
297
298
|
- app/controllers/liquidum/variables_controller.rb
|
|
298
299
|
- app/helpers/liquidum/application_helper.rb
|
|
299
300
|
- app/jobs/liquidum/application_job.rb
|
|
@@ -341,6 +342,7 @@ files:
|
|
|
341
342
|
- lib/liquidum/liquid/parser.rb
|
|
342
343
|
- lib/liquidum/liquid/tags/helper_tag.rb
|
|
343
344
|
- lib/liquidum/liquid/tags/render_tag.rb
|
|
345
|
+
- lib/liquidum/tags.rb
|
|
344
346
|
- lib/liquidum/variable.rb
|
|
345
347
|
- lib/liquidum/variables.rb
|
|
346
348
|
- lib/liquidum/version.rb
|