inversion 1.3.1 → 1.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
- checksums.yaml.gz.sig +0 -0
- data/Examples.md +134 -0
- data/GettingStarted.md +50 -0
- data/Guide.md +14 -0
- data/{History.rdoc → History.md} +52 -43
- data/{README.rdoc → README.md} +43 -34
- data/Tags.md +555 -0
- data/bin/inversion +4 -8
- data/lib/inversion/cli/api.rb +75 -0
- data/lib/inversion/cli/tagtokens.rb +34 -0
- data/lib/inversion/cli/tree.rb +70 -0
- data/lib/inversion/cli.rb +406 -0
- data/lib/inversion/exceptions.rb +0 -1
- data/lib/inversion/mixins.rb +10 -11
- data/lib/inversion/parser.rb +5 -6
- data/lib/inversion/refinements.rb +18 -0
- data/lib/inversion/renderstate.rb +24 -25
- data/lib/inversion/sinatra.rb +0 -1
- data/lib/inversion/template/attrtag.rb +7 -5
- data/lib/inversion/template/begintag.rb +0 -1
- data/lib/inversion/template/calltag.rb +0 -1
- data/lib/inversion/template/codetag.rb +37 -28
- data/lib/inversion/template/commenttag.rb +0 -1
- data/lib/inversion/template/configtag.rb +3 -4
- data/lib/inversion/template/containertag.rb +1 -2
- data/lib/inversion/template/defaulttag.rb +1 -2
- data/lib/inversion/template/elsetag.rb +0 -1
- data/lib/inversion/template/elsiftag.rb +0 -1
- data/lib/inversion/template/endtag.rb +2 -3
- data/lib/inversion/template/escapetag.rb +1 -2
- data/lib/inversion/template/fortag.rb +2 -3
- data/lib/inversion/template/fragmenttag.rb +1 -2
- data/lib/inversion/template/iftag.rb +3 -1
- data/lib/inversion/template/importtag.rb +2 -3
- data/lib/inversion/template/includetag.rb +1 -2
- data/lib/inversion/template/node.rb +4 -5
- data/lib/inversion/template/pptag.rb +1 -2
- data/lib/inversion/template/publishtag.rb +2 -3
- data/lib/inversion/template/rescuetag.rb +1 -2
- data/lib/inversion/template/subscribetag.rb +3 -4
- data/lib/inversion/template/tag.rb +3 -4
- data/lib/inversion/template/textnode.rb +1 -2
- data/lib/inversion/template/timedeltatag.rb +1 -2
- data/lib/inversion/template/unlesstag.rb +0 -1
- data/lib/inversion/template/uriencodetag.rb +1 -2
- data/lib/inversion/template/yieldtag.rb +0 -1
- data/lib/inversion/template.rb +18 -22
- data/lib/inversion/tilt.rb +1 -2
- data/lib/inversion.rb +2 -3
- data/spec/helpers.rb +19 -13
- data/spec/inversion/mixins_spec.rb +1 -1
- data/spec/inversion/monkeypatches_spec.rb +1 -1
- data/spec/inversion/parser_spec.rb +1 -1
- data/spec/inversion/renderstate_spec.rb +1 -1
- data/spec/inversion/sinatra_spec.rb +1 -1
- data/spec/inversion/template/attrtag_spec.rb +1 -1
- data/spec/inversion/template/begintag_spec.rb +1 -1
- data/spec/inversion/template/calltag_spec.rb +1 -1
- data/spec/inversion/template/codetag_spec.rb +24 -1
- data/spec/inversion/template/commenttag_spec.rb +1 -1
- data/spec/inversion/template/configtag_spec.rb +1 -1
- data/spec/inversion/template/containertag_spec.rb +1 -1
- data/spec/inversion/template/defaulttag_spec.rb +1 -1
- data/spec/inversion/template/elsetag_spec.rb +1 -1
- data/spec/inversion/template/elsiftag_spec.rb +1 -1
- data/spec/inversion/template/endtag_spec.rb +1 -1
- data/spec/inversion/template/escapetag_spec.rb +1 -1
- data/spec/inversion/template/fortag_spec.rb +1 -1
- data/spec/inversion/template/fragmenttag_spec.rb +1 -1
- data/spec/inversion/template/iftag_spec.rb +1 -1
- data/spec/inversion/template/importtag_spec.rb +1 -1
- data/spec/inversion/template/includetag_spec.rb +1 -1
- data/spec/inversion/template/node_spec.rb +1 -1
- data/spec/inversion/template/pptag_spec.rb +1 -1
- data/spec/inversion/template/publishtag_spec.rb +1 -1
- data/spec/inversion/template/rescuetag_spec.rb +1 -1
- data/spec/inversion/template/subscribetag_spec.rb +1 -1
- data/spec/inversion/template/tag_spec.rb +1 -1
- data/spec/inversion/template/textnode_spec.rb +1 -1
- data/spec/inversion/template/timedeltatag_spec.rb +1 -1
- data/spec/inversion/template/unlesstag_spec.rb +1 -1
- data/spec/inversion/template/uriencodetag_spec.rb +1 -1
- data/spec/inversion/template/yieldtag_spec.rb +1 -1
- data/spec/inversion/template_spec.rb +1 -1
- data/spec/inversion/tilt_spec.rb +1 -1
- data/spec/inversion_spec.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +59 -45
- metadata.gz.sig +0 -0
- data/Examples.rdoc +0 -134
- data/GettingStarted.rdoc +0 -44
- data/Guide.rdoc +0 -47
- data/Manifest.txt +0 -86
- data/Rakefile +0 -7
- data/Tags.rdoc +0 -560
- data/lib/inversion/command.rb +0 -278
- data/lib/inversion/monkeypatches.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5303515e3e875a3c5ed98c9e0a8ac874892997214298548ca4640849344465c
|
4
|
+
data.tar.gz: d2fb3f646b2e09934705a89b680c411d1fb9b0ad38dd0bf863ec25534f6ae85d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ea0c5321afd08e14d5bb8a1e86a53f7905d1092098f2f06ef1d51e590000154c81fc576e4d4ff6fd4faf677c5ae44babc9e634e1236ed10dbb10d628ad36b40
|
7
|
+
data.tar.gz: 3a30aac016541f7e625283ccc4544306c8c375097932e8dede95479a61bffebfe1ac9e5352879e65055ed9fc97130519da0868a4c24a920115f531ef81178a47
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Examples.md
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# Annotated Examples
|
2
|
+
|
3
|
+
This is a list of template examples with annotations explaining what each group of lines is doing.
|
4
|
+
|
5
|
+
## Simple Examples
|
6
|
+
|
7
|
+
...
|
8
|
+
|
9
|
+
|
10
|
+
## Advanced Examples
|
11
|
+
|
12
|
+
Here's a somewhat more complex example. At our company Spime-Thorpe from above, say we're creating a system that will handle mass layoffs without the need for management to handle all those messy personal interactions. We'll need a mass-mailer for the employees that will be afforded the chance to explore their career opportunities, right? So we create a template called `overboard-mail.tmpl`:
|
13
|
+
|
14
|
+
<?config debugging_comments: true ?>
|
15
|
+
<?default grace_period to "7 days" ?>
|
16
|
+
|
17
|
+
<?begin?>
|
18
|
+
<p>Dear <?call employee.fullname ?>,</p>
|
19
|
+
<?rescue DatabaseError ?>
|
20
|
+
<p>Dear Valued Ex-Employee,</p>
|
21
|
+
<?end begin?>
|
22
|
+
|
23
|
+
<p>Congratulations! You have been selected by <?call failed_company.name ?>'s
|
24
|
+
elite management team as one of the many lucky individuals that will
|
25
|
+
enjoy the exciting challenge of pursuing other rewarding employment
|
26
|
+
opportunities!</p>
|
27
|
+
|
28
|
+
<p><em>Kudos!</em></p>
|
29
|
+
|
30
|
+
<p>You will find your accounts have been disabled, your desk has been helpfully
|
31
|
+
cleared out for you, and all of your personal effects packaged up and
|
32
|
+
delivered to your address of record approximately
|
33
|
+
<?timedelta tracking_info.delivery_date ?>:</p>
|
34
|
+
|
35
|
+
<?for line in employee.address ?>
|
36
|
+
<?attr line ?><br />
|
37
|
+
<?end for ?>
|
38
|
+
|
39
|
+
<p>Please visit your <a href="[?call config.overboard_url ?]/[?uriencode
|
40
|
+
failed_company.id ?]/[?uriencode employee.id ?]">customized Man OverBoard
|
41
|
+
transition site</a> immediately:</p>
|
42
|
+
|
43
|
+
<p>This will acknowledge that you have received this message, and automatically
|
44
|
+
disable your email account. Be sure and save this message!</p>
|
45
|
+
|
46
|
+
<?if employee.severance_amount.nonzero? ?>
|
47
|
+
<p>Failure to acknowledge this message within <?attr grace_period ?> could result
|
48
|
+
in delay of your final severance pay, in the amount of
|
49
|
+
<?call "$%0.2f" % employee.severance_amount ?>.</p>
|
50
|
+
<?else?>
|
51
|
+
<p>Failure to acknowledge this message within <?attr grace_period ?> will
|
52
|
+
result in automatic forfeiture of your numerous Man Overboard package benefits.</p>
|
53
|
+
<?end if?>
|
54
|
+
|
55
|
+
<?comment Disabled at client request ?>
|
56
|
+
If you have any questions or concerns, please don't hesitate to contact your
|
57
|
+
friendly Spime-Thorpe <a href="mailto:salesteam2@spime-thorpe.com">representative</a>.
|
58
|
+
<?end comment ?>
|
59
|
+
|
60
|
+
<p>Good Luck,<br />
|
61
|
+
Your friends at Spime-Thorpe, Inc!<br />
|
62
|
+
<a href="http://www.spime-thorpe.com/">http://www.spime-thorpe.com/</a></p>
|
63
|
+
|
64
|
+
When wrapped with a layout template, here's what this renders as:
|
65
|
+
|
66
|
+
<?example { language: xml, caption: "The rendered output for one lucky individual" } ?>
|
67
|
+
<!DOCTYPE html>
|
68
|
+
<!--
|
69
|
+
|
70
|
+
Spime-Thorpe!
|
71
|
+
$Id$
|
72
|
+
|
73
|
+
-->
|
74
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
75
|
+
<head>
|
76
|
+
<title>Spime-Thorpe: Untitled</title>
|
77
|
+
|
78
|
+
<link rel="stylesheet" src="/css/base.css" type="text/css" />
|
79
|
+
|
80
|
+
<script type="text/javascript" src="/js/jquery-latest.min.js"></script>
|
81
|
+
|
82
|
+
</head>
|
83
|
+
<body>
|
84
|
+
|
85
|
+
<header>
|
86
|
+
<hgroup>
|
87
|
+
<h1>Spime-Thorpe</h1>
|
88
|
+
<h2></h2>
|
89
|
+
</hgroup>
|
90
|
+
</header>
|
91
|
+
|
92
|
+
<section id="content">
|
93
|
+
<p>Dear James Random,</p>
|
94
|
+
|
95
|
+
<p>Congratulations! You have been selected by Widgets R Us's
|
96
|
+
elite management team as one of the many lucky individuals that will
|
97
|
+
enjoy the exciting challenge of pursuing other rewarding employment
|
98
|
+
opportunities!</p>
|
99
|
+
|
100
|
+
<p><em>Kudos!</em></p>
|
101
|
+
|
102
|
+
<p>You will find your accounts have been disabled, your desk has been helpfully
|
103
|
+
cleared out for you, and all of your personal effects packaged up and
|
104
|
+
delivered to your address of record approximately
|
105
|
+
3 days ago:</p>
|
106
|
+
|
107
|
+
1213 NE. Winding Road<br />
|
108
|
+
Syracuse, NY 100213<br />
|
109
|
+
|
110
|
+
<p>Please visit your <a href="http://failedcompany.spime-thorpe.com/overboard/a18661/1881">
|
111
|
+
customized Man OverBoard transition site</a> immediately:</p>
|
112
|
+
|
113
|
+
<p>This will acknowledge that you have received this message, and automatically
|
114
|
+
disable your email account. Be sure and save this message!</p>
|
115
|
+
|
116
|
+
<p>Failure to acknowledge this message within 11 days could result
|
117
|
+
in delay of your final severance pay, in the amount of
|
118
|
+
$12.81.</p>
|
119
|
+
|
120
|
+
|
121
|
+
<p>Good Luck,<br />
|
122
|
+
Your friends at Spime-Thorpe, Inc!<br />
|
123
|
+
<a href="http://www.spime-thorpe.com/">http://www.spime-thorpe.com/</a></p>
|
124
|
+
</section>
|
125
|
+
|
126
|
+
<footer>
|
127
|
+
<section id="copyright">Copyright 2011, Spime-Thorpe</section>
|
128
|
+
</footer>
|
129
|
+
|
130
|
+
</body>
|
131
|
+
</html>
|
132
|
+
|
133
|
+
This example can be found in the Inversion repository, in the `experiments` directory.
|
134
|
+
|
data/GettingStarted.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Getting Started
|
2
|
+
|
3
|
+
## Requirements
|
4
|
+
|
5
|
+
- Ruby 2.7.5 or later
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
$ gem install inversion
|
11
|
+
|
12
|
+
|
13
|
+
## Basic Usage
|
14
|
+
|
15
|
+
Inversion, like most other templating systems, works by giving you a way of
|
16
|
+
defining the static parts of your output, and then letting you combine that at
|
17
|
+
a later point with the dynamic parts:
|
18
|
+
|
19
|
+
Create the template and use it to render an exciting message:
|
20
|
+
|
21
|
+
tmpl = Inversion::Template.new( "Hello, <?attr name ?>!" )
|
22
|
+
tmpl.name = "World"
|
23
|
+
puts tmpl.render
|
24
|
+
|
25
|
+
The `<?attr name ?>` tag defines the _name_ accessor on the
|
26
|
+
[template](rdoc-ref:Templates) object, the value of which is substituted for
|
27
|
+
any occurrences of `name` in the template:
|
28
|
+
|
29
|
+
Hello, World!
|
30
|
+
|
31
|
+
This by itself isn't fantastically useful, but it does illustrate one of the
|
32
|
+
ways in which Inversion is different: the program and the template share data
|
33
|
+
through an API, instead of through a complex data structure, which establishes
|
34
|
+
a clear delineation between what responsibility is the program's and which is
|
35
|
+
the template's. The program doesn't have to know how the view uses the data
|
36
|
+
it's given, and tests of the controller can substitute a Mock Object for the
|
37
|
+
template to test the interaction between the two instead of having to match
|
38
|
+
patterns in the eventual output like an integration test.
|
39
|
+
|
40
|
+
You can also interact with the values set in the template:
|
41
|
+
|
42
|
+
Name: <?attr employee.full_name ?>
|
43
|
+
|
44
|
+
This will call the #full_name method on whatever is set as the `employee`
|
45
|
+
attribute when rendered, and the result will take the place of the tag.
|
46
|
+
|
47
|
+
Inversion also comes with a collection of [other tags](rdoc-ref:Tags) that
|
48
|
+
provide flow control, exception-handling, etc.
|
49
|
+
|
50
|
+
|
data/Guide.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Inversion User's Guide
|
2
|
+
|
3
|
+
Inversion is a templating system for Ruby. It uses the Inversion of Control principle to decouple
|
4
|
+
the contents and structure of the template from the code that uses it, making it easier to use,
|
5
|
+
test-friendly, and clean.
|
6
|
+
|
7
|
+
[Getting Started](rdoc-ref:GettingStarted) goes over the requirements, installation, and basic usage of the library.
|
8
|
+
|
9
|
+
The rdoc-ref:Templates topic has more details about how to load templates and control their behavior with options.
|
10
|
+
|
11
|
+
When you're ready to start making your own templates, there's a quick-reference for the list of built-in rdoc-ref:Tags, too.
|
12
|
+
|
13
|
+
Finally, there are a number of [Annotated Examples](rdoc-ref:Examples) that illustrate how to solve common problems while templating.
|
14
|
+
|
data/{History.rdoc → History.md}
RENAMED
@@ -1,8 +1,17 @@
|
|
1
|
-
|
1
|
+
# Release History for inversion
|
2
2
|
|
3
3
|
---
|
4
4
|
|
5
|
-
|
5
|
+
## v1.4.0 [2022-12-21] Michael Granger <ged@faeriemud.org>
|
6
|
+
|
7
|
+
Improvements:
|
8
|
+
|
9
|
+
- Update for Ruby 3, modernize RSpec setup
|
10
|
+
- Convert CLI to GLI+TTY
|
11
|
+
- Fix up error class in codetag.
|
12
|
+
|
13
|
+
|
14
|
+
## v1.3.1 [2020-09-29] Michael Granger <ged@faeriemud.org>
|
6
15
|
|
7
16
|
Improvements:
|
8
17
|
|
@@ -10,14 +19,14 @@ Improvements:
|
|
10
19
|
- Handle HTML encoding for uriencoding tag ourselves
|
11
20
|
|
12
21
|
|
13
|
-
|
22
|
+
## v1.3.0 [2020-04-08] Mahlon E. Smith <mahlon@martini.nu>
|
14
23
|
|
15
24
|
- Use safe_yaml when deserializing config tag contents.
|
16
25
|
- Un-hoeify.
|
17
26
|
- Updates for Ruby 2.7.
|
18
27
|
|
19
28
|
|
20
|
-
|
29
|
+
## v1.2.0 [2019-05-14] Michael Granger <ged@FaerieMUD.org>
|
21
30
|
|
22
31
|
Enhancements:
|
23
32
|
|
@@ -26,14 +35,14 @@ Enhancements:
|
|
26
35
|
'decorators' optional.
|
27
36
|
|
28
37
|
|
29
|
-
|
38
|
+
## v1.1.1 [2017-11-13] Michael Granger <ged@FaerieMUD.org>
|
30
39
|
|
31
40
|
Bugfixes:
|
32
41
|
|
33
42
|
- Yield subarrays in `each` tags when there's only one block argument (#3).
|
34
43
|
|
35
44
|
|
36
|
-
|
45
|
+
## v1.1.0 [2017-08-17] Mahlon E. Smith <mahlon@martini.nu>
|
37
46
|
|
38
47
|
Enhancements:
|
39
48
|
|
@@ -44,17 +53,17 @@ Enhancements:
|
|
44
53
|
parents matcher patterns.
|
45
54
|
|
46
55
|
|
47
|
-
|
56
|
+
## v1.0.0 [2017-01-16] Michael Granger <ged@FaerieMUD.org>
|
48
57
|
|
49
58
|
Mark as stable, update dependencies.
|
50
59
|
|
51
60
|
|
52
|
-
|
61
|
+
## v0.18.0 [2015-10-01] Michael Granger <ged@FaerieMUD.org>
|
53
62
|
|
54
63
|
Add a `strict_attributes` option for templates.
|
55
64
|
|
56
65
|
|
57
|
-
|
66
|
+
## v0.17.4 [2015-07-08] Michael Granger <ged@FaerieMUD.org>
|
58
67
|
|
59
68
|
Fixes:
|
60
69
|
|
@@ -62,14 +71,14 @@ Fixes:
|
|
62
71
|
Galanakis <rob.galanakis@gmail.com>.
|
63
72
|
|
64
73
|
|
65
|
-
|
74
|
+
## v0.17.3 [2015-02-16] Michael Granger <ged@FaerieMUD.org>
|
66
75
|
|
67
76
|
- Performance fix: Re-comment the #inspect logging message
|
68
77
|
in the RenderState
|
69
78
|
- Updated tag docs
|
70
79
|
|
71
80
|
|
72
|
-
|
81
|
+
## v0.17.2 [2015-01-22] Michael Granger <ged@FaerieMUD.org>
|
73
82
|
|
74
83
|
- Fix a bug with the fragment tag.
|
75
84
|
|
@@ -77,35 +86,35 @@ Fragments will now propagate to the container template when they're
|
|
77
86
|
added by inner templates.
|
78
87
|
|
79
88
|
|
80
|
-
|
89
|
+
## v0.17.1 [2015-01-15] Michael Granger <ged@FaerieMUD.org>
|
81
90
|
|
82
91
|
Re-push to fix a misbuilt gem.
|
83
92
|
|
84
93
|
|
85
|
-
|
94
|
+
## v0.17.0 [2015-01-15] Michael Granger <ged@FaerieMUD.org>
|
86
95
|
|
87
96
|
Support snakecase tag names/tag filenames
|
88
97
|
|
89
98
|
|
90
|
-
|
99
|
+
## v0.16.0 [2015-01-14] Michael Granger <ged@FaerieMUD.org>
|
91
100
|
|
92
101
|
Add support for loading templates from an alternate path
|
93
102
|
via :template_paths option to Inversion::Template.load.
|
94
103
|
|
95
104
|
|
96
|
-
|
105
|
+
## v0.15.0 [2014-11-24] Michael Granger <ged@FaerieMUD.org>
|
97
106
|
|
98
107
|
Add a mechanism to allow tags to extend the template.
|
99
108
|
|
100
109
|
|
101
|
-
|
110
|
+
## v0.14.0 [2014-11-05] Michael Granger <ged@FaerieMUD.org>
|
102
111
|
|
103
112
|
- Add the fragment tag and docs
|
104
113
|
- Remove old manual doc artifacts. Add documentation for the
|
105
114
|
'begin/rescue' and 'default' tags.
|
106
115
|
|
107
116
|
|
108
|
-
|
117
|
+
## v0.13.0 [2014-04-23] Michael Granger <ged@FaerieMUD.org>
|
109
118
|
|
110
119
|
- Carry global configuration into instantiated template options.
|
111
120
|
- Documentation update.
|
@@ -113,90 +122,90 @@ Add a mechanism to allow tags to extend the template.
|
|
113
122
|
(Never released.)
|
114
123
|
|
115
124
|
|
116
|
-
|
125
|
+
## v0.12.3 [2013-09-20] Michael Granger <ged@FaerieMUD.org>
|
117
126
|
|
118
127
|
- Don't deep_copy IOs or Tempfiles (bugfix).
|
119
128
|
|
120
129
|
|
121
|
-
|
130
|
+
## v0.12.2 [2013-06-19] Michael Granger <ged@FaerieMUD.org>
|
122
131
|
|
123
132
|
- Fix propagation of config tags into subtemplates (fixes #1)
|
124
133
|
- Use replacement in transcoding instead of raising encoding errors
|
125
134
|
|
126
135
|
|
127
|
-
|
136
|
+
## v0.12.1 [2013-03-05] Michael Granger <ged@FaerieMUD.org>
|
128
137
|
|
129
138
|
A bunch of optimization and inspect-encoding fixes.
|
130
139
|
|
131
140
|
|
132
|
-
|
141
|
+
## v0.12.0 [2013-03-01] Michael Granger <ged@FaerieMUD.org>
|
133
142
|
|
134
143
|
- Make exceptions rendered as comments include the backtrace if
|
135
144
|
debugging comments are enabled.
|
136
145
|
|
137
146
|
|
138
|
-
|
147
|
+
## v0.11.2 [2012-09-17] Michael Granger <ged@FaerieMUD.org>
|
139
148
|
|
140
149
|
- [bugfix] Don't cast enumerated values in for tags to Arrays.
|
141
150
|
|
142
151
|
|
143
|
-
|
152
|
+
## v0.11.1 [2012-09-17] Michael Granger <ged@FaerieMUD.org>
|
144
153
|
|
145
154
|
- [bugfix] Make subscriptions get nodes that were already published
|
146
155
|
|
147
156
|
|
148
|
-
|
157
|
+
## v0.11.0 [2012-07-06] Michael Granger <ged@FaerieMUD.org>
|
149
158
|
|
150
159
|
- Automatically transcode output according to the registered encoding
|
151
160
|
if the template is created with one
|
152
161
|
|
153
162
|
|
154
|
-
|
163
|
+
## v0.10.2 [2012-06-27] Mahlon E. Smith <mahlon@martini.nu>
|
155
164
|
|
156
165
|
- Bugfix: Don't dup Classes and Modules in template attributes.
|
157
166
|
- Optimization: Don't needlessly duplicate the node tree on template
|
158
167
|
duplication.
|
159
168
|
|
160
169
|
|
161
|
-
|
170
|
+
## v0.10.1 [2012-06-22] Michael Granger <ged@FaerieMUD.org>
|
162
171
|
|
163
172
|
- Bugfix: duplicated templates get distinct copies of their attributes.
|
164
173
|
|
165
174
|
|
166
|
-
|
175
|
+
## v0.10.0 [2012-05-07] Michael Granger <ged@FaerieMUD.org>
|
167
176
|
|
168
177
|
- Added signature for changeset 9d9c49d532be
|
169
178
|
|
170
|
-
|
179
|
+
## v0.10.0 [2012-05-07] Michael Granger <ged@FaerieMUD.org>
|
171
180
|
|
172
181
|
- Convert to Loggability for logging.
|
173
182
|
|
174
183
|
|
175
|
-
|
184
|
+
## v0.9.0 [2012-04-24] Michael Granger <ged@FaerieMUD.org>
|
176
185
|
|
177
186
|
- Split the template path out from the config into a class instance variable.
|
178
187
|
- Documentation update.
|
179
188
|
|
180
189
|
|
181
|
-
|
190
|
+
## v0.8.0 [2012-04-01] Michael Granger <ged@FaerieMUD.org>
|
182
191
|
|
183
192
|
- Optimization fixes
|
184
193
|
- Fixed rendering flow control to not use a begin/rescue.
|
185
194
|
|
186
195
|
|
187
|
-
|
196
|
+
## v0.7.0 [2012-03-29] Michael Granger <ged@FaerieMUD.org>
|
188
197
|
|
189
198
|
- Switch to a much more flexible way to render tag bodies. This should
|
190
199
|
resolve most of the problems we've encountered with complex templates.
|
191
200
|
|
192
201
|
|
193
|
-
|
202
|
+
## v0.6.1 [2012-03-16] Michael Granger <ged@FaerieMUD.org>
|
194
203
|
|
195
204
|
- Commented out some of the more expensive debug logging for an order
|
196
205
|
of magnitude increase in render speed.
|
197
206
|
|
198
207
|
|
199
|
-
|
208
|
+
## v0.6.0 [2012-03-13] Michael Granger <ged@FaerieMUD.org>
|
200
209
|
|
201
210
|
- Fix a bug with "for" tag iteration over complex data structures
|
202
211
|
- Add a configurable delay for checking for changes on file-based
|
@@ -206,13 +215,13 @@ A bunch of optimization and inspect-encoding fixes.
|
|
206
215
|
- Handle Configurability's configure-with-defaults call.
|
207
216
|
|
208
217
|
|
209
|
-
|
218
|
+
## v0.5.0 [2012-01-05] Michael Granger <ged@FaerieMUD.org>
|
210
219
|
|
211
220
|
Added an encoding option to Inversion::Template.load for
|
212
221
|
specifying the encoding of the template source.
|
213
222
|
|
214
223
|
|
215
|
-
|
224
|
+
## v0.4.0 [2011-10-05] Michael Granger <ged@FaerieMUD.org>
|
216
225
|
|
217
226
|
Reworked render toggling so the before/after rendering hooks are
|
218
227
|
called immediately before and after the node *would* have been
|
@@ -223,14 +232,14 @@ demark aren't even touched if rendering is disabled.
|
|
223
232
|
Adjusted the other tags to account for the change.
|
224
233
|
|
225
234
|
|
226
|
-
|
235
|
+
## v0.3.0 [2011-10-05] Michael Granger <ged@FaerieMUD.org>
|
227
236
|
|
228
237
|
- Fix require loop in if/elsif tags
|
229
238
|
- Fixing a problem with HTML escaping of objects other than Strings
|
230
239
|
- Added render timing (Inversion::RenderState#time_elapsed)
|
231
240
|
|
232
241
|
|
233
|
-
|
242
|
+
## v0.2.0 [2011-09-27] Michael Granger <ged@FaerieMUD.org>
|
234
243
|
|
235
244
|
- Bugfixes (#1, #2)
|
236
245
|
- Renamed Inversion::Template::Parser to Inversion::Parser
|
@@ -238,18 +247,18 @@ Adjusted the other tags to account for the change.
|
|
238
247
|
per-render basis.
|
239
248
|
|
240
249
|
|
241
|
-
|
250
|
+
## v0.1.1 [2011-09-23] Michael Granger <ged@FaerieMUD.org>
|
242
251
|
|
243
252
|
- Bugfix for the Subscribe tag.
|
244
253
|
|
245
254
|
|
246
|
-
|
255
|
+
## v0.1.0 [2011-09-23] Michael Granger <ged@FaerieMUD.org>
|
247
256
|
|
248
257
|
- Added template reloading via Inversion::Template#changed?
|
249
258
|
and #reload.
|
250
259
|
|
251
260
|
|
252
|
-
|
261
|
+
## v0.0.4 [2011-09-21] Michael Granger <ged@FaerieMUD.org>
|
253
262
|
|
254
263
|
- Avoid Pathname#expand_path in Inversion::Template.load
|
255
264
|
[optimization]
|
@@ -258,17 +267,17 @@ Adjusted the other tags to account for the change.
|
|
258
267
|
- Added a manual
|
259
268
|
|
260
269
|
|
261
|
-
|
270
|
+
## v0.0.3 [2011-08-15] Michael Granger <ged@FaerieMUD.org>
|
262
271
|
|
263
272
|
- Dependency fix
|
264
273
|
|
265
274
|
|
266
|
-
|
275
|
+
## v0.0.2 [2011-08-15] Michael Granger <ged@FaerieMUD.org>
|
267
276
|
|
268
277
|
- Packaging fix
|
269
278
|
|
270
279
|
|
271
|
-
|
280
|
+
## v0.0.1 [2011-02-02] Michael Granger <ged@FaerieMUD.org>
|
272
281
|
|
273
282
|
Initial release.
|
274
283
|
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,12 +1,19 @@
|
|
1
|
-
|
1
|
+
# inversion
|
2
2
|
|
3
|
-
home
|
4
|
-
|
5
|
-
github:: https://github.com/ged/inversion
|
6
|
-
docs:: http://deveiate.org/code/Inversion
|
3
|
+
home
|
4
|
+
: https://hg.sr.ht/~ged/Inversion
|
7
5
|
|
6
|
+
code
|
7
|
+
: https://hg.sr.ht/~ged/Inversion/browse
|
8
8
|
|
9
|
-
|
9
|
+
github
|
10
|
+
: https://github.com/ged/inversion
|
11
|
+
|
12
|
+
docs
|
13
|
+
: http://deveiate.org/code/Inversion
|
14
|
+
|
15
|
+
|
16
|
+
## Description
|
10
17
|
|
11
18
|
Inversion is a templating system for Ruby. It uses the "Inversion of Control"
|
12
19
|
principle to decouple the contents and structure of templates from the code
|
@@ -14,7 +21,7 @@ that uses them, making it easier to separate concerns, keep your tests simple,
|
|
14
21
|
and avoid polluting scopes with ephemeral data.
|
15
22
|
|
16
23
|
|
17
|
-
|
24
|
+
### Details
|
18
25
|
|
19
26
|
Inversion, like most other templating systems, works by giving you a way of
|
20
27
|
defining the static parts of your output, and then letting you combine that at
|
@@ -22,12 +29,12 @@ a later point with the dynamic parts:
|
|
22
29
|
|
23
30
|
Create the template and use it to render an exciting message:
|
24
31
|
|
25
|
-
|
26
|
-
|
27
|
-
|
32
|
+
tmpl = Inversion::Template.new( "Hello, <?attr name ?>!" )
|
33
|
+
tmpl.name = "World"
|
34
|
+
puts tmpl.render
|
28
35
|
|
29
|
-
The
|
30
|
-
object, the value of which is substituted for any occurrences of
|
36
|
+
The `<?attr name ?>` tag defines the _name_ accessor on the template
|
37
|
+
object, the value of which is substituted for any occurrences of `name` in the
|
31
38
|
template:
|
32
39
|
|
33
40
|
Hello, World!
|
@@ -45,15 +52,15 @@ You can also interact with the values set in the template:
|
|
45
52
|
|
46
53
|
Name: <?attr employee.full_name ?>
|
47
54
|
|
48
|
-
This will call the
|
55
|
+
This will call the #full_name method on whatever is set as the `employee`
|
49
56
|
attribute when rendered, and the result will take the place of the tag.
|
50
57
|
|
51
|
-
Inversion also comes with
|
58
|
+
Inversion also comes with [a collection of other tags](rdoc-ref:Tags) that
|
52
59
|
provide flow control, exception-handling, etc.
|
53
60
|
|
54
61
|
Here's a slightly more complex example: Say we have a layout template that
|
55
62
|
contains all the boilerplate, navigation, etc. for the site, and then an
|
56
|
-
|
63
|
+
`<?attr body ?>` somewhere in the content area for the content specific to
|
57
64
|
each view:
|
58
65
|
|
59
66
|
layout = Inversion::Template.load( 'templates/layout.tmpl' )
|
@@ -70,8 +77,8 @@ Then there's a view template that displays a bulleted list of article titles:
|
|
70
77
|
</section>
|
71
78
|
|
72
79
|
Loading this template results in a Ruby object whose API contains one method:
|
73
|
-
|
74
|
-
an
|
80
|
+
`#articles`. To render the view, we just call that accessor with instances of
|
81
|
+
an `Article` domain class we defined elsewhere, and then drop the `alist`
|
75
82
|
template into the layout and render them:
|
76
83
|
|
77
84
|
alist = Inversion::Template.load( 'templates/alist.tmpl' )
|
@@ -80,8 +87,8 @@ template into the layout and render them:
|
|
80
87
|
layout.body = alist
|
81
88
|
puts layout.render
|
82
89
|
|
83
|
-
The
|
84
|
-
generate an
|
90
|
+
The `for` tag in the alist will iterate over the enumerable Articles and
|
91
|
+
generate an `<li>` for each one. The resulting template object will be set as
|
85
92
|
the body of the layout template, and stringified when the enclosing template
|
86
93
|
is rendered. Templates can be nested this way as deeply as you like.
|
87
94
|
|
@@ -89,43 +96,45 @@ For detailed tag documentation and examples, start with the Inversion::Template
|
|
89
96
|
class in the API documentation.
|
90
97
|
|
91
98
|
|
92
|
-
|
99
|
+
## References
|
93
100
|
|
94
|
-
*
|
95
|
-
*
|
96
|
-
*
|
101
|
+
* Inversion of Control - https://en.wikipedia.org/wiki/Inversion_of_control
|
102
|
+
* Passive View - https://martinfowler.com/eaaDev/PassiveScreen.html
|
103
|
+
* Supervising Controller - https://martinfowler.com/eaaDev/SupervisingPresenter.html
|
97
104
|
|
98
105
|
|
99
|
-
|
106
|
+
## Installation
|
100
107
|
|
101
108
|
gem install inversion
|
102
109
|
|
103
110
|
|
104
|
-
|
111
|
+
## Contributing
|
105
112
|
|
106
113
|
You can check out the current development source
|
107
|
-
|
108
|
-
project's
|
114
|
+
[with Mercurial](https://hg.sr.ht/~ged/Inversion), or if you prefer Git, via the
|
115
|
+
project's [Github mirror](https://github.com/ged/Inversion).
|
109
116
|
|
110
117
|
You can submit bug reports, suggestions, and read more about future plans at
|
111
|
-
|
118
|
+
[the project page](https://hg.sr.ht/~ged/Inversion).
|
112
119
|
|
113
120
|
After checking out the source, run:
|
114
121
|
|
115
|
-
|
122
|
+
$ gem install -Ng
|
123
|
+
$ rake setup
|
124
|
+
|
125
|
+
This task will install any missing dependencies and do any necessary developer
|
126
|
+
setup.
|
116
127
|
|
117
|
-
This task will install any missing dependencies, run the tests/specs,
|
118
|
-
and generate the API documentation.
|
119
128
|
|
120
|
-
|
129
|
+
## Authors
|
121
130
|
|
122
131
|
* Michael Granger <ged@faeriemud.org>
|
123
132
|
* Mahlon E. Smith <mahlon@martini.nu>
|
124
133
|
|
125
134
|
|
126
|
-
|
135
|
+
## License
|
127
136
|
|
128
|
-
Copyright © 2011-
|
137
|
+
Copyright © 2011-2022, Michael Granger and Mahlon E. Smith
|
129
138
|
All rights reserved.
|
130
139
|
|
131
140
|
Redistribution and use in source and binary forms, with or without
|