opulent 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +3 -3
- data/docs/attributes.md +164 -0
- data/docs/control-structures.md +91 -0
- data/docs/reference.md +9 -0
- data/lib/opulent/version.rb +1 -1
- metadata +4 -3
- data/Rakefile +0 -6
- data/docs/syntax.md +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4e6711a377fd5f4bdb35c0d1acb44a542e2ad86
|
4
|
+
data.tar.gz: 2df71d3a64fb210a6b0853285fff5d82e4a7363c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20aa32c2d2edf206eef8eafaff65255fe0039ad10cfdaa92af9be2fdd890d1d91c99dd38b46780c28e8ba86cb76bd0c0207b6a06388fb1ee925dc5149eedd2d7
|
7
|
+
data.tar.gz: a4a00b6cb4be54cb77a56aba84978e8a3e196b299c8bab178c721770ec508297476f97d98742942aa4a1965c870826ab7db44dc5add25549f4e031d7ef7d5890
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Opulent
|
2
2
|
|
3
|
-
Opulent is an __Intelligent Web Templating Engine__ created for
|
3
|
+
Opulent is an __Intelligent Web Templating Engine__ created for extremely fast and efficient Web Development. Based on the idea of lightweight and reusable __Web Components__, Opulent greatly increases your development speed for any project.
|
4
4
|
|
5
5
|
## Syntax
|
6
6
|
|
7
|
-
Opulent
|
7
|
+
Opulent has a beautiful, minimalistic syntax: no tags, indentation based, optional brackets, inline text, inline children and in page definitions.
|
8
8
|
|
9
9
|
__Page Markup__
|
10
10
|
```
|
@@ -40,7 +40,7 @@ ul.navbar
|
|
40
40
|
|
41
41
|
__Starting to feel it?__ There's so much more you can do with Opulent.
|
42
42
|
|
43
|
-
[Read the Documentation](docs/
|
43
|
+
[Read the Documentation](docs/reference.md)
|
44
44
|
|
45
45
|
|
46
46
|
|
data/docs/attributes.md
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
# Opulent Attributes
|
2
|
+
Tag attributes are similar to CSS or HTML, but their values are regular embedded Ruby.
|
3
|
+
|
4
|
+
### Shorthand Attributes
|
5
|
+
You can use the shorthand attributes exactly as you would in your CSS markup, the syntax is very similar.
|
6
|
+
|
7
|
+
The default node for the shorthand attributes is the __div__ node, since it's the most widely used HTML Element.
|
8
|
+
|
9
|
+
__Example__
|
10
|
+
```scss
|
11
|
+
.container.text-center
|
12
|
+
|
13
|
+
#content
|
14
|
+
|
15
|
+
#main.center
|
16
|
+
|
17
|
+
div#block.new
|
18
|
+
|
19
|
+
input&email
|
20
|
+
```
|
21
|
+
|
22
|
+
```html
|
23
|
+
<div class="container text-center"></div>
|
24
|
+
|
25
|
+
<div id="content"></div>
|
26
|
+
|
27
|
+
<div id="main" class="center"></div>
|
28
|
+
|
29
|
+
<div id="block" class="new"></div>
|
30
|
+
|
31
|
+
<input name="email">
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
### Wrapped Attributes
|
36
|
+
You can either use equals symbol '__=__' or colon symbol '__:__' to set a value for an attribute.
|
37
|
+
|
38
|
+
The difference between wrapped and unwrapped (inline) attributes is that you can use complex Ruby expressions such as boolean operations, comparisons or ternary operators.
|
39
|
+
|
40
|
+
The attributes in wrapped mode are separated by a comma '__,__' or semicolon '__;__'.
|
41
|
+
|
42
|
+
The node's __class__ attribute values are gathered into an array, while the other attributes will be replaced.
|
43
|
+
|
44
|
+
Attributes can be wrapped in round __(exp)__, square __[exp]__ and curly __{exp}__ brackets.
|
45
|
+
|
46
|
+
__Example 1__
|
47
|
+
```html
|
48
|
+
a(href="http://google.com") Google
|
49
|
+
a(href: "http://google.com") Google
|
50
|
+
|
51
|
+
a[href="http://google.com"] Google
|
52
|
+
a[href: "http://google.com"] Google
|
53
|
+
|
54
|
+
a{href="http://google.com"} Google
|
55
|
+
a{href: "http://google.com"} Google
|
56
|
+
```
|
57
|
+
|
58
|
+
```html
|
59
|
+
<a href="http://google.com">Google</a>
|
60
|
+
```
|
61
|
+
|
62
|
+
__Example 2__
|
63
|
+
|
64
|
+
```html
|
65
|
+
div(class: "HELLO".downcase, class: "world")
|
66
|
+
```
|
67
|
+
|
68
|
+
```html
|
69
|
+
<div class="hello world"></div>
|
70
|
+
```
|
71
|
+
|
72
|
+
__Example 3__
|
73
|
+
```html
|
74
|
+
a(class=["btn", "btn-primary"])
|
75
|
+
```
|
76
|
+
|
77
|
+
```html
|
78
|
+
<a class="btn btn-primary"></a>
|
79
|
+
```
|
80
|
+
|
81
|
+
__Example 4__
|
82
|
+
```html
|
83
|
+
example(attr1=1 + 2 + 3, attr2="hello " + "world")
|
84
|
+
```
|
85
|
+
|
86
|
+
```html
|
87
|
+
<example attr1="6" attr2="hello world"></example>
|
88
|
+
```
|
89
|
+
|
90
|
+
### Unwrapped Attributes
|
91
|
+
Inline attributes can be used without any wrapping brackets and they allow you to use simple expressions such as method calls and index accessors.
|
92
|
+
|
93
|
+
__Example 1__
|
94
|
+
```html
|
95
|
+
a href="http://google.com" Google
|
96
|
+
|
97
|
+
a href="http://google.com" class="button" Google
|
98
|
+
```
|
99
|
+
|
100
|
+
```
|
101
|
+
<a href="http://google.com">Google</a>
|
102
|
+
|
103
|
+
<a href="http://google.com" class="button">Google</a>
|
104
|
+
```
|
105
|
+
|
106
|
+
__Example 2__
|
107
|
+
```html
|
108
|
+
a class=["btn", "btn-primary"] Button
|
109
|
+
```
|
110
|
+
|
111
|
+
```html
|
112
|
+
<a class="btn btn-primary">Button</a>
|
113
|
+
```
|
114
|
+
|
115
|
+
### Escaping Attributes
|
116
|
+
Attributes are escaped by default, unless passed as node definition arguments.
|
117
|
+
|
118
|
+
You can use a tilde symbol '__~__' after the assignment operator to explicitly set the attribute value as unescaped.
|
119
|
+
|
120
|
+
__Example__
|
121
|
+
```html
|
122
|
+
div escaped="<div></div>"
|
123
|
+
div unescaped=~"<div></div>"
|
124
|
+
```
|
125
|
+
|
126
|
+
```html
|
127
|
+
<div escaped="<div></div>"></div>
|
128
|
+
<div unescaped="<div></div>"></div>
|
129
|
+
```
|
130
|
+
|
131
|
+
Unescaped buffered code can be dangerous. You must be sure to sanitize any user inputs to avoid cross-site scripting.
|
132
|
+
|
133
|
+
### Extending Attributes
|
134
|
+
Attributes can be extended using a '__+__' symbol, followed by an expression which returns a Hash.
|
135
|
+
|
136
|
+
__Example__
|
137
|
+
```html
|
138
|
+
a+({href: "http://opulent.io", class: "btn btn-black"}) Opulent
|
139
|
+
```
|
140
|
+
```html
|
141
|
+
<a href="http://opulent.io" class="btn btn-black">Opulent</a>
|
142
|
+
```
|
143
|
+
|
144
|
+
|
145
|
+
### Literal Values
|
146
|
+
In Opulent, boolean values, arrays and hashes behave differently based on the use context. Arrays will join values using a space when used for class attributes and an underline otherwise. Hashes will extend the current attribute name one level using the hash key.
|
147
|
+
|
148
|
+
__Example 1__
|
149
|
+
```html
|
150
|
+
- hash = {a: 1, b: 2, c: 3}
|
151
|
+
div data=hash
|
152
|
+
```
|
153
|
+
|
154
|
+
```html
|
155
|
+
<div data-a="1" data-b="2" data-c="3"></div>
|
156
|
+
```
|
157
|
+
|
158
|
+
```html
|
159
|
+
- array = ['a', 'b', 'c']
|
160
|
+
div data=array class=array
|
161
|
+
```
|
162
|
+
```html
|
163
|
+
<div data="a_b_c" class="a b c"></div>
|
164
|
+
```
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# Opulent Control Structures
|
2
|
+
|
3
|
+
You can use your favorite control structures from Ruby in Opulent without any hassle. Unlike in most templating engines, control structures do not require a leading dash and can be written like you normally write a node.
|
4
|
+
|
5
|
+
### If Structure
|
6
|
+
Just like in Ruby, you can use the __if-elsif-else__ structure to write conditional branches. The values false and nil are false, and everything else are true. Notice Ruby and Opulent use elsif, not else if nor elif.
|
7
|
+
|
8
|
+
__Example__
|
9
|
+
```html
|
10
|
+
if user.authenticated?
|
11
|
+
p Welcome #{user.name}
|
12
|
+
else
|
13
|
+
p Welcome stranger!
|
14
|
+
```
|
15
|
+
|
16
|
+
### Unless Structure
|
17
|
+
The branch is executed if the condition is false. The unless structure also allows an else branch.
|
18
|
+
|
19
|
+
__Example__
|
20
|
+
```html
|
21
|
+
unless value
|
22
|
+
p Value doesn't exist
|
23
|
+
```
|
24
|
+
|
25
|
+
### Case Structure
|
26
|
+
To handle multiple possible values, the case structure is preferred instead of the if-elsif structure.
|
27
|
+
|
28
|
+
__Example__
|
29
|
+
```html
|
30
|
+
- value = 'a'
|
31
|
+
|
32
|
+
case value
|
33
|
+
when 'a'
|
34
|
+
p This is a
|
35
|
+
when 'b'
|
36
|
+
p This is b
|
37
|
+
when 'c'
|
38
|
+
p This is c
|
39
|
+
else
|
40
|
+
p This is something else
|
41
|
+
```
|
42
|
+
|
43
|
+
### Each Structure
|
44
|
+
The each structure will iterate through an ennumerable value such as an Array or Hash and allow you to use
|
45
|
+
the value and the current index. By default, the variable names are '__key__' and '__value__' but they can be overwritten.
|
46
|
+
|
47
|
+
__Example 1__
|
48
|
+
```html
|
49
|
+
each in ['a', 'b', 'c']
|
50
|
+
p Value at #{key} is #{value}.
|
51
|
+
```
|
52
|
+
|
53
|
+
```html
|
54
|
+
<p>Value at 0 is a.</p>
|
55
|
+
<p>Value at 1 is b.</p>
|
56
|
+
<p>Value at 2 is c.</p>
|
57
|
+
```
|
58
|
+
|
59
|
+
__Example 2__
|
60
|
+
```html
|
61
|
+
each myval in ['1', '2', '3']
|
62
|
+
p Value at #{key} is #{myval}.
|
63
|
+
```
|
64
|
+
|
65
|
+
__Example 3__
|
66
|
+
```html
|
67
|
+
each k, v in {a: '1', b: '2', c: '3'}
|
68
|
+
p Value at #{k} is #{v}.
|
69
|
+
```
|
70
|
+
|
71
|
+
### While Structure
|
72
|
+
The while structure will loop until we encounter a false value for the conditional. You will need to update the conditional variables inside the while loop in order to eventually reach a false value, otherwise it will result in an infinite loop.
|
73
|
+
|
74
|
+
__Example__
|
75
|
+
```html
|
76
|
+
- timer = 10
|
77
|
+
while timer > 0
|
78
|
+
p Time remaining: #{timer}
|
79
|
+
- timer -= 1
|
80
|
+
```
|
81
|
+
|
82
|
+
### Until Structure
|
83
|
+
The until structure will loop until we encounter a true value for the conditional.
|
84
|
+
|
85
|
+
__Example__
|
86
|
+
```html
|
87
|
+
- timer = 10
|
88
|
+
until timer == 0
|
89
|
+
p Time left: #{timer}
|
90
|
+
- timer -= 1
|
91
|
+
```
|
data/docs/reference.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#Opulent
|
2
|
+
Opulent is an __Intelligent Web Templating Engine__ created for extremely fast and efficient Web Development. Based on the idea of lightweight and reusable __Web Components__, Opulent greatly increases your development speed for any project.
|
3
|
+
|
4
|
+
### Language Reference
|
5
|
+
|
6
|
+
1. [Attributes](attributes.md)
|
7
|
+
2. [Control Structures](control-structures.md)
|
8
|
+
3. [Expressions](usage.md)
|
9
|
+
4. [Comments](usage.md)
|
data/lib/opulent/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opulent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Grozav
|
@@ -129,13 +129,14 @@ files:
|
|
129
129
|
- Gemfile
|
130
130
|
- LICENSE
|
131
131
|
- README.md
|
132
|
-
- Rakefile
|
133
132
|
- benchmark/benchmark.rb
|
134
133
|
- benchmark/cases/node/node.haml
|
135
134
|
- benchmark/cases/node/node.op
|
136
135
|
- benchmark/cases/node/node.slim
|
137
136
|
- bin/opulent
|
138
|
-
- docs/
|
137
|
+
- docs/attributes.md
|
138
|
+
- docs/control-structures.md
|
139
|
+
- docs/reference.md
|
139
140
|
- docs/usage.md
|
140
141
|
- lib/opulent.rb
|
141
142
|
- lib/opulent/compiler.rb
|
data/Rakefile
DELETED
data/docs/syntax.md
DELETED