inversion 1.3.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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} +59 -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/lib/roda/plugins/inversion.rb +225 -0
- data/spec/helpers.rb +19 -13
- data/spec/inversion/mixins_spec.rb +1 -1
- data/spec/inversion/parser_spec.rb +1 -1
- data/spec/inversion/refinements_spec.rb +22 -0
- 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/spec/roda/plugins/inversion_spec.rb +91 -0
- data.tar.gz.sig +0 -0
- metadata +90 -58
- 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
- data/spec/inversion/monkeypatches_spec.rb +0 -25
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
|