opulent 1.8.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76bdc4c7325218912ef5e71007f9d64f7342b0e9
4
- data.tar.gz: 79d52447ddcbaa17c138998e278a270febf2cff5
3
+ metadata.gz: eb391e9dc419cbe3860f6439e74f4af66fb0bb2f
4
+ data.tar.gz: 7a6314283b3e23907a04b6f3ed36669f26431c05
5
5
  SHA512:
6
- metadata.gz: ad0e14bd3dddc7e32ebcabcccf0696aed4cdfd79e790cdd65f866c967d3559b2da7ace8c21ce0b25a5dfe28f5dc32c3247b0d13b83d583c7a65049685971279f
7
- data.tar.gz: d0ecfc90dfb792a0410fc50d7b44d6bfec78eb135b19edf6e0abdbbbc10548e0edf3d93bede9bd48225e80c4273d63cbe4a614997bc4d0b714244471fff92085
6
+ metadata.gz: ad945c888025afb1ecfff5bc45e71de36bfdf13602386a636f6bde25b4fa6b524954e460f56be94f3d740da986fb86d44b7c229b772b1160b1c213895d351e08
7
+ data.tar.gz: b8c67846a876db18702f33b80c9f1832c37d1321571e86d3dcd45fbafce58dfa4fbcc5d0df2320dcebc2cde5e45a8a24a4608248ac38e50d915f8c154663076c
data/.gitignore CHANGED
@@ -8,3 +8,5 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  *.DS_Store
11
+ node_modules/*
12
+ src/*
data/README.md CHANGED
@@ -1,12 +1,11 @@
1
- # Opulent
1
+ # Opulent [http://opulent.io](http://opulent.io)
2
2
  [![Build Status](https://travis-ci.org/opulent/opulent.svg?branch=master)](https://travis-ci.org/opulent/opulent)
3
3
 
4
- 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
+ Opulent is a templating engine which strives to make page markup as beautiful and expressive as it should be. It's blazing fast, offers useful reusable component definitions and encourages well organised front end code. Opulent provides the cleanliness, readability and development speed you need for your project.
5
5
 
6
- [Read the Documentation](docs/reference.md)
6
+ [Visit Homepage](http://opulent.io/)
7
7
 
8
8
  ## Syntax
9
-
10
9
  Opulent has a beautiful, minimalistic syntax: no tags, indentation based, optional brackets, inline text, inline children and in page definitions.
11
10
 
12
11
  __Page Markup__
@@ -24,14 +23,24 @@ html
24
23
  With Opulent, you can do anything.
25
24
  ```
26
25
 
27
- __Web Component__
26
+ __Reusable Component__
28
27
  ```
29
28
  def hello(place)
30
29
  p Hello #{place}
31
-
30
+
32
31
  hello place="World"
33
32
  ```
34
33
 
34
+ ```
35
+ def content
36
+ #content
37
+ yield
38
+
39
+ content
40
+ h1 I'll replace yield!
41
+ ```
42
+
43
+
35
44
  __Control Structures__
36
45
  ```
37
46
  ul.navbar
@@ -41,9 +50,21 @@ ul.navbar
41
50
  li > a href=link_to_register Sign Up
42
51
  ```
43
52
 
44
- __Starting to feel it?__ There's so much more you can do with Opulent.
53
+ ### Elegant
54
+ Markup should beautiful and clean. Opulent makes markup a pleasant experience.
55
+
56
+ ### Reusable
57
+ Completely DRY, in opulent you can define reusable markup elements easily.
45
58
 
46
- [Read the Documentation](docs/reference.md)
59
+ ### Full Featured
60
+ Everything you need, right from the start. Ready for all the major Ruby frameworks.
61
+
62
+ ### Performant
63
+ Opulent is lightweight, blazing fast. Performance is measured with every release.
64
+
65
+ __Like it?__ There's so much more you can do with Opulent.
66
+
67
+ [Read the Documentation](http://opulent.io/documentation/)
47
68
 
48
69
 
49
70
 
@@ -70,35 +91,23 @@ And then execute:
70
91
 
71
92
  Using Opulent to render a file is as easy as including it in your application and using the render method.
72
93
 
73
- [Read the Documentation](docs/usage.md)
94
+ [Read the Documentation](http://opulent.io/documentation/)
74
95
 
75
96
  ```ruby
76
97
  require 'opulent'
77
98
 
78
- Opulent.new.render_file :index
99
+ engine = Opulent.new(:index)
100
+ output = engine.render
79
101
  ```
80
102
 
81
- <!--
82
- ## Development
83
-
84
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
85
-
86
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
87
- -->
88
-
89
103
  ## Contributing
90
104
 
91
105
  Bug reports and pull requests are welcome on GitHub at https://github.com/opulent/opulent. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
92
106
 
93
- #### Under Development
94
- Opulent is currently in the Beta Phase. It has serious potential to becoming the next generation of Templating Engines for Ruby, therefore any contribution is more than welcome.
107
+ #### Production Ready
108
+ Opulent is production ready and has serious potential to becoming the next generation of Templating Engines for Ruby, therefore any contribution is more than welcome.
95
109
 
96
- It still has development going on the following subjects:
97
110
 
98
- * Template amble (preamble, cache, postamble) generation
99
- * More block yielding tests
100
- * Multiple page layouts
101
- * More to come
102
111
 
103
112
  ## License
104
113
 
@@ -59,7 +59,7 @@ module Opulent
59
59
  @block_stack = []
60
60
 
61
61
  # Remember last compiled node, required for pretty printing purposes
62
- @sibling_stack = [[[:root, nil]]]
62
+ @sibling_stack = [[[:root, nil]], []]
63
63
 
64
64
  # Set parent node, required for pretty printing
65
65
  @parent_stack = []
@@ -9,9 +9,11 @@ module Opulent
9
9
  #
10
10
  def comment(node, indent)
11
11
  buffer_freeze "\n" if node[@options][:newline]
12
+ buffer_freeze " " * indent if @settings[:pretty]
12
13
  buffer_freeze '<!-- '
13
14
  buffer_split_by_interpolation node[@value].strip, false
14
15
  buffer_freeze ' -->'
16
+ buffer_freeze "\n" if @settings[:pretty]
15
17
  end
16
18
  end
17
19
  end
@@ -33,6 +33,7 @@ module Opulent
33
33
 
34
34
  @node_stack << :doctype
35
35
  buffer_freeze "<#{value}>"
36
+ buffer_freeze "\n" if @settings[:pretty]
36
37
  end
37
38
  end
38
39
  end
@@ -15,19 +15,21 @@ module Opulent
15
15
  inline = Settings::INLINE_NODE.include? node[@value]
16
16
 
17
17
  if inline
18
- if @sibling_stack[-1][-1][0] == :plain
18
+ if @sibling_stack[-1][-1] && @sibling_stack[-1][-1][0] == :plain
19
19
  buffer_remove_trailing_whitespace
20
+ elsif @sibling_stack[-1].length == 1
21
+ buffer_freeze indentation
20
22
  end
21
23
  else
22
24
  buffer_freeze indentation
23
25
  end
24
26
 
25
27
  @sibling_stack[-1] << [node[@type], node[@value]]
26
- @sibling_stack << [[node[@type], node[@value]]]
28
+ @sibling_stack << [ [node[@type], node[@value]] ]
27
29
  end
28
30
 
29
31
  # Add the tag opening, with leading whitespace to the code buffer
30
- buffer_freeze ' ' if node[@options][:leading_whitespace]
32
+ buffer_freeze ' ' if node[@options][:leading_whitespace]
31
33
  buffer_freeze "<#{node[@value]}"
32
34
 
33
35
  # Evaluate node extension in the current context
@@ -67,7 +69,10 @@ module Opulent
67
69
 
68
70
  # Pretty print
69
71
  if @settings[:pretty]
70
- buffer_freeze "\n" if node[@children].size > 0 and !inline
72
+ if node[@children].length > 0
73
+ buffer_freeze "\n" unless inline
74
+ end
75
+ # @sibling_stack << [[node[@type], node[@value]]]
71
76
  end
72
77
 
73
78
  # Process each child element recursively, increasing indentation
@@ -77,7 +82,8 @@ module Opulent
77
82
 
78
83
  # Pretty print
79
84
  if @settings[:pretty]
80
- if node[@children].size > 1 &&
85
+ if node[@children].length > 1 &&
86
+ @sibling_stack[-1][-1] &&
81
87
  (@sibling_stack[-1][-1][0] == :plain ||
82
88
  Settings::INLINE_NODE.include?(@sibling_stack[-1][-1][1]))
83
89
  buffer_freeze "\n"
@@ -14,7 +14,8 @@ module Opulent
14
14
  # Pretty print
15
15
  if @settings[:pretty]
16
16
  indentation = ' ' * indent
17
- inline = @sibling_stack[-1][-1][0] == :node &&
17
+
18
+ inline = @sibling_stack[-1][-1] && @sibling_stack[-1][-1][0] == :node &&
18
19
  Settings::INLINE_NODE.include?(@sibling_stack[-1][-1][1])
19
20
 
20
21
  # Add current node to the siblings stack
@@ -22,10 +23,14 @@ module Opulent
22
23
 
23
24
  # If we have a text on multiple lines and the text isn't supposed to be
24
25
  # inline, indent all the lines of the text
25
- if !inline || value.split("\n").size > 1
26
- value.gsub!(/^(?!$)/, indentation)
26
+ if node[@value] == :text
27
+ if !inline
28
+ value.gsub!(/^(?!$)/, indentation)
29
+ else
30
+ value.strip!
31
+ end
27
32
  else
28
- value.strip!
33
+ buffer_freeze indentation
29
34
  end
30
35
  end
31
36
 
@@ -17,9 +17,8 @@ module Opulent
17
17
 
18
18
  # Update render settings
19
19
  #
20
+ # @param input [Symbol/String] Input code or file
20
21
  # @param settings [Hash] Opulent settings override
21
- # @param def [Hash] def from previously parsed files
22
- # @param overwrite [Boolean] Write changes directly to the parent binding
23
22
  #
24
23
  def initialize(input, settings = {})
25
24
  # Update default settings with user settings
@@ -6,7 +6,7 @@ module Opulent
6
6
  # In case no match was found, throw an exception.
7
7
  # In special cases, modify the token hash.
8
8
  #
9
- # @param nodes [Array] Parent node to which we append to
9
+ # @param parent [Array] Parent node to which we append to
10
10
  #
11
11
  def root(parent = @root, min_indent = -1)
12
12
  while (@line = @code[(@i += 1)])
@@ -1,4 +1,4 @@
1
1
  # @Opulent
2
2
  module Opulent
3
- VERSION = '1.8.0'
3
+ VERSION = '1.8.1'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opulent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Grozav
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-10 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.4.6
185
+ rubygems_version: 2.5.1
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Intelligent Templating Engine for Creative Web Developers.