htmler 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3b4c5843e087c49cf3805a05e8937f00735d29b5
4
+ data.tar.gz: 8d34c075e0f98d645bebf55e1a9d26d4ac20c2fe
5
+ SHA512:
6
+ metadata.gz: d819315ee8e3ba4dfa96dfcb3d26159e987b542b055edb7e466af5a221a3e329059ae2bc2b87826b1a49e4e33e94d8fd0fea00db13a167d6dd93ff02f0ada972
7
+ data.tar.gz: 9470b92957c964ecd9d31c872f28a3a7c1b0e44ba1e7877b5ca786613c0f15214e4be73596268b09568c9f3af015fc681b8c90c3938d068edc8e5d70248c60ab
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Htmler
2
+
3
+ Htmler is a Ruby DSL to write HTML without the need to close tags all the time, making the job more pleasurable: the ruby way. With Htmler it is easier to write fast prototypes, generate static sites and (in the future) serve Htmler template format pages.
4
+
5
+ ---
6
+
7
+ ### Example
8
+
9
+ ```ruby
10
+ html {
11
+ head {
12
+ title { 'Hello world!' }
13
+ }
14
+ body {
15
+ header {
16
+ h1 { 'Site title' }
17
+ }
18
+ div {
19
+ div {
20
+ p { 'From the FIRST div' }
21
+ }
22
+ div {
23
+ p { 'From the SECOND div' }
24
+ p { '...and another one' }
25
+ }
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ will generate (but compressed) this HTML...
32
+
33
+ ```html
34
+ <html>
35
+ <head>
36
+ <title>Hello world!</title>
37
+ </head>
38
+ <body>
39
+ <header>
40
+ <h1>Site title</h1>
41
+ </header>
42
+ <div>
43
+ <div><p>From the FIRST div</p></div>
44
+ <div>
45
+ <p>From the SECOND div</p>
46
+ <p>...and another one</p>
47
+ </div>
48
+ </div>
49
+ </body>
50
+ </html>
51
+ ```
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec) do |t|
4
+ t.rspec_opts = %w[--color]
5
+ end
data/bin/htmler ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'htmler'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'htmler'
8
+ end
9
+
10
+ htmler = Htmler.new
11
+ htmler.compile_file(ARGV[0])
12
+ puts htmler.to_html
data/htmler.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "htmler/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "htmler"
6
+ s.version = Htmler.VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Hugo Abonizio"]
9
+ s.email = ["hugo_abonizio@hotmail.com"]
10
+ s.homepage = "https://github.com/hugoabonizio/htmler"
11
+ s.summary = %q{Rubyst way to write HTML}
12
+ s.description = %q{A Ruby DSL to write HTML}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+ end
data/lib/htmler.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'htmler/base'
2
+ require 'htmler/version'
@@ -0,0 +1,35 @@
1
+ class Htmler
2
+ undef_method :p
3
+
4
+ def initialize
5
+ @_result = ''
6
+ end
7
+
8
+ def to_html
9
+ @_result
10
+ end
11
+
12
+ def method_missing(name, *args, &block)
13
+ @_result += "<#{name}>"
14
+ if block_given?
15
+ _return = block.call
16
+ @_result += _return unless _return.nil?
17
+ end
18
+ @_result += "</#{name}>"
19
+
20
+ # print the temporary stack
21
+ # puts "> #{@_result}"
22
+
23
+ nil
24
+
25
+ end
26
+
27
+ def compile(input)
28
+ instance_eval(input)
29
+ end
30
+
31
+ def compile_file(name)
32
+ instance_eval(File.new(name).readlines.join)
33
+ end
34
+
35
+ end
@@ -0,0 +1,5 @@
1
+ class Htmler
2
+ def self.VERSION
3
+ "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ html {
2
+
3
+ head {
4
+ title { 'Hello world!' }
5
+ }
6
+
7
+ body {
8
+ header {
9
+ h1 { 'Site title' }
10
+ }
11
+ div {
12
+ div {
13
+ p { 'From the FIRST div' }
14
+ }
15
+ div {
16
+ p { 'From the SECOND div' }
17
+ p { '...and another one' }
18
+ }
19
+ }
20
+
21
+ }
22
+
23
+ }
@@ -0,0 +1,5 @@
1
+ html {
2
+ head {
3
+ title { "lol" }
4
+ }
5
+ }
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Htmler do
4
+ before do
5
+ @htmler = Htmler.new
6
+ end
7
+ it "should respond to to_html" do
8
+
9
+ expect(@htmler.respond_to? 'to_html'). to be_true
10
+ end
11
+
12
+ it "should compile a string" do
13
+ @htmler.compile('html { head { title { "lol" } } }')
14
+ expect(@htmler.to_html).to eql('<html><head><title>lol</title></head></html>')
15
+ end
16
+
17
+ it "should compile a file" do
18
+ @htmler.compile_file('spec/files/simple_html_head_title.htmler')
19
+ expect(@htmler.to_html).to eql('<html><head><title>lol</title></head></html>')
20
+ end
21
+
22
+ it "should parse a more complex file" do
23
+ @htmler.compile_file('spec/files/moderate1.htmler')
24
+ expect(@htmler.to_html).to eql('<html><head><title>Hello world!</title></head><body><header><h1>Site title</h1></header><div><div><p>From the FIRST div</p></div><div><p>From the SECOND div</p><p>...and another one</p></div></div></body></html>')
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/../lib/htmler.rb"
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: htmler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hugo Abonizio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Ruby DSL to write HTML
14
+ email:
15
+ - hugo_abonizio@hotmail.com
16
+ executables:
17
+ - htmler
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - README.md
23
+ - Rakefile
24
+ - bin/htmler
25
+ - htmler.gemspec
26
+ - lib/htmler.rb
27
+ - lib/htmler/base.rb
28
+ - lib/htmler/version.rb
29
+ - spec/files/moderate1.htmler
30
+ - spec/files/simple_html_head_title.htmler
31
+ - spec/htmler_spec.rb
32
+ - spec/spec_helper.rb
33
+ homepage: https://github.com/hugoabonizio/htmler
34
+ licenses: []
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 2.2.2
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Rubyst way to write HTML
56
+ test_files: []