dang 1.0.0.rc3 → 1.0.0.rc4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 921e16bc25d57d7d9bb54ca3549bfa22eeca70c4
4
- data.tar.gz: 65e62f8ea4bc62059bf6e0ab9eb170b6c080b8b4
3
+ metadata.gz: 3cdcb2f62d81a1f8314380d5f288cdd3f68891a3
4
+ data.tar.gz: d5384936dce8d468b9ad34123df0c7b082fb690d
5
5
  SHA512:
6
- metadata.gz: e10eab2a35238fb1afad8806e6d27a51ba360f1eb2aa4869f50f67f90a8477f9c460db15529f7bca14a583379ef41e03b5d741fc250f50b0b553931c697392f6
7
- data.tar.gz: 601b1c03479ccad637c39dc65ca59a0d4157f095136d2ef25cf3cc8d8ee155eb979c6c5fbd220ecf426f80af0df99cc8a77a22f7909ddd6b548de3b26c5bafab
6
+ metadata.gz: 65cbe439dede9b19747e5e13c56a52db56b6777b5872c8267cebb45b62c562fed859ae8a5827b44f0306da6eb3df650db74282c063d462155de4781f44c4e21d
7
+ data.tar.gz: cb8e43201252121c97169f76c295c22128a1c8388ef92f41dcc93e41fad0fd8515a398af06dc3649158f338da415dfd080962c31c017a0e6bec330ab8d5ff030
@@ -0,0 +1,9 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/
5
+ .sass-cache/
6
+ .DS_Store
7
+ .rvmrc
8
+ *.dat
9
+ pkg
@@ -0,0 +1,2 @@
1
+ .git/
2
+ spectory/
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - rbx-18mode
7
+ - rbx-19mode
8
+ - jruby-18mode
9
+ - jruby-19mode
@@ -1,4 +1,7 @@
1
1
  .autotest
2
+ .gitignore
3
+ .hoeignore
4
+ .travis.yml
2
5
  Gemfile
3
6
  Gemfile.lock
4
7
  History.md
@@ -7,7 +10,9 @@ README.md
7
10
  Rakefile
8
11
  TODO.md
9
12
  bin/dang
13
+ dang.gemspec
10
14
  lib/dang.rb
11
15
  lib/dang/dang.rb
12
16
  lib/dang/parser.kpeg
13
17
  lib/dang/parser.rb
18
+ lib/dang/rails.rb
data/README.md CHANGED
@@ -2,35 +2,43 @@
2
2
 
3
3
  https://github.com/veganstraightedge/dang
4
4
 
5
+
5
6
  ## Description
6
7
 
7
- Another dang templating language.
8
+ Dang is a Ruby templating language
9
+ It uses angle brackets and CSS syntax.
10
+ Somewhere between ERB and Haml.
11
+
8
12
 
9
13
  ## Build Status
10
14
 
11
15
  [![Build Status](https://travis-ci.org/veganstraightedge/dang.png?branch=master)](https://travis-ci.org/veganstraightedge/dang)
12
16
 
17
+
13
18
  ## Features
14
19
 
15
- * CSS selectors for HTML tags
20
+ * CSS selectors for HTML tags + attributes
16
21
  * Not as noisy syntax than ERB
17
- * Not quite as elegant as [HAML](http://haml.info)
22
+ * Not quite as elegant as [Haml](http://haml.info)
18
23
  * No %s in your code
19
- * More closers than HAML
20
- * A lot is based on / inspired by [HAML](http://haml.info)
24
+ * More closers than Haml
25
+ * A lot is based on / inspired by [Haml](http://haml.info)
26
+
21
27
 
22
28
  ## Synopsis
29
+ ### Syntax
23
30
 
24
- * **Syntax**: `<tag content tag>`
25
- * **Syntax**: `<tag#id content tag>`
26
- * **Syntax**: `<tag#class content tag>`
27
- * **Syntax**: `<tag[attr=value] content tag>`
28
- * **Syntax**: `<! html comment !>`
29
- * **Syntax**: Embedded non-printing ruby (<- if logged_in? ->)
30
- * **Syntax**: Embedded printing ruby (<= @user.name =>)
31
- * **Syntax**: `!!!` doctype shorthand inspired by HAML
31
+ * `<b a simple bold tag b>`
32
+ * `<div#id div with an id div>`
33
+ * `<p.class lorem ipsum p>`
34
+ * `<a[href=/] Home a>`
35
+ * `<! html comment !>`
36
+ * `<- non_printing(ruby) ->`
37
+ * `<= printing(ruby) =>`
38
+ * `!!!` doctype shorthand inspired by HAML
32
39
 
33
- ## Synopsis
40
+
41
+ ## Usage
34
42
 
35
43
  From the command line, transform a file of dang into html:
36
44
 
@@ -40,17 +48,22 @@ Or just a snippet of dang into html:
40
48
 
41
49
  `dang -e "<i snippet i>"`
42
50
 
51
+
43
52
  ## Current Version
44
53
 
45
- 1.0.0.rc3
54
+ 1.0.0.rc4
55
+
46
56
 
47
57
  ## Requirements
48
58
 
59
+ For development:
60
+
49
61
  * [rake](https://github.com/jimweirich/rake)
50
62
  * [kpeg](https://github.com/evanphx/kpeg)
51
63
  * [hoe](https://github.com/seattlerb/hoe)
52
64
  * [minitest](https://github.com/seattlerb/minitest)
53
65
 
66
+
54
67
  ## Installation
55
68
 
56
69
  ### Gemfile
@@ -69,7 +82,8 @@ Or install it yourself as:
69
82
  gem install dang
70
83
  ```
71
84
 
72
- You may need to use `sudo` to install it manually.
85
+ You may need to use`sudo` to install it manually.
86
+
73
87
 
74
88
  ## Developers
75
89
 
@@ -81,11 +95,13 @@ bundle
81
95
 
82
96
  This task will install any missing dependencies, run the tests/specs, and generate the RDoc.
83
97
 
98
+
84
99
  ## Authors
85
100
 
86
101
  * Shane Becker / [@veganstraightedge](https://github.com/veganstraightedge)
87
102
  * Evan Phoenix / [@evanphx](https://github.com/evanphx)
88
103
 
104
+
89
105
  ## Contributing
90
106
 
91
107
  1. Fork it
@@ -99,6 +115,7 @@ This task will install any missing dependencies, run the tests/specs, and genera
99
115
  If you find bugs, have feature requests or questions, please
100
116
  [file an issue](https://github.com/veganstraightedge/dang).
101
117
 
118
+
102
119
  ## License
103
120
 
104
121
  **PUBLIC DOMAIN**
data/Rakefile CHANGED
@@ -3,13 +3,16 @@ require "hoe"
3
3
 
4
4
  Hoe.plugins.delete :rubyforge
5
5
  Hoe.plugin :doofus, :git
6
+ Hoe.plugin :ignore
6
7
 
7
- Hoe.spec "dang" do
8
+ HOE = Hoe.spec "dang" do
8
9
  developer "Shane Becker", "veganstraightedge@gmail.com"
9
10
 
10
- self.extra_rdoc_files = Dir["*.rdoc"]
11
- self.history_file = "History.md"
12
- self.readme_file = "README.md"
11
+ self.extra_rdoc_files = Dir["*.rdoc"]
12
+ self.history_file = "History.md"
13
+ self.readme_file = "README.md"
14
+ self.licenses << "PUBLIC DOMAIN"
15
+ self.licenses << "CC0"
13
16
  end
14
17
 
15
18
  task :parser do
@@ -28,3 +31,11 @@ task :spec do
28
31
 
29
32
  Minitest.autorun
30
33
  end
34
+
35
+ file "#{HOE.spec.name}.gemspec" => ['Rakefile', "lib/dang/dang.rb"] do |t|
36
+ puts "Generating #{t.name}"
37
+ File.open(t.name, 'wb') { |f| f.write HOE.spec.to_ruby }
38
+ end
39
+
40
+ desc "Generate or update the standalone gemspec file for the project"
41
+ task :gemspec => ["#{HOE.spec.name}.gemspec"]
data/bin/dang CHANGED
@@ -4,12 +4,25 @@ require 'dang'
4
4
  require 'optparse'
5
5
 
6
6
  to_eval = nil
7
- path = nil
7
+ path = nil
8
+ version = false
8
9
 
9
10
  opt = OptionParser.new do |o|
11
+ o.banner = "Usage: dang [options] [input.dang] [output.html]"
12
+
10
13
  o.on "-e STR", "Evaluate the string as Dang" do |s|
11
14
  to_eval = s
12
15
  end
16
+
17
+ o.on "-v", "--version", "Print the version of Dang" do
18
+ puts "dang #{Dang::VERSION}, codename: #{Dang::CODENAME}"
19
+ version = true
20
+ end
21
+
22
+ o.on "-h", "--help", "Print, well, this" do
23
+ puts opt
24
+ exit
25
+ end
13
26
  end
14
27
 
15
28
  opt.parse! ARGV
@@ -18,9 +31,23 @@ if to_eval
18
31
  puts Dang.it(to_eval)
19
32
 
20
33
  else
21
- path = ARGV.shift
22
- if !path
23
- raise "Specify -e or a path to a file"
34
+ input = ARGV.shift
35
+
36
+ if !input
37
+ exit if version
38
+ puts opt
39
+ exit 1
40
+ end
41
+
42
+ data = Dang.it(File.read(input))
43
+
44
+ if output = ARGV.shift
45
+ File.open output, "w" do |f|
46
+ f.puts data
47
+ end
48
+
49
+ puts "Wrote HTML to '#{output}'"
50
+ else
51
+ puts data
24
52
  end
25
- puts Dang.it(File.read(path))
26
53
  end
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "dang"
5
+ s.version = "1.0.0.rc4"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Shane Becker"]
9
+ s.date = "2013-08-09"
10
+ s.description = "Dang is a Ruby templating language\nIt uses angle brackets and CSS syntax.\nSomewhere between ERB and Haml."
11
+ s.email = ["veganstraightedge@gmail.com"]
12
+ s.executables = ["dang"]
13
+ s.extra_rdoc_files = ["Manifest.txt"]
14
+ s.files = [".autotest", ".gitignore", ".hoeignore", ".travis.yml", "Gemfile", "Gemfile.lock", "History.md", "Manifest.txt", "README.md", "Rakefile", "TODO.md", "bin/dang", "dang.gemspec", "lib/dang.rb", "lib/dang/dang.rb", "lib/dang/parser.kpeg", "lib/dang/parser.rb", "lib/dang/rails.rb"]
15
+ s.homepage = "https://github.com/veganstraightedge/dang"
16
+ s.licenses = ["PUBLIC DOMAIN", "CC0"]
17
+ s.rdoc_options = ["--main", "README.md"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = "dang"
20
+ s.rubygems_version = "2.0.3"
21
+ s.summary = "Dang is a Ruby templating language It uses angle brackets and CSS syntax"
22
+
23
+ if s.respond_to? :specification_version then
24
+ s.specification_version = 4
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ s.add_development_dependency(%q<rdoc>, ["~> 3.10"])
28
+ s.add_development_dependency(%q<hoe>, ["~> 3.5"])
29
+ else
30
+ s.add_dependency(%q<rdoc>, ["~> 3.10"])
31
+ s.add_dependency(%q<hoe>, ["~> 3.5"])
32
+ end
33
+ else
34
+ s.add_dependency(%q<rdoc>, ["~> 3.10"])
35
+ s.add_dependency(%q<hoe>, ["~> 3.5"])
36
+ end
37
+ end
@@ -2,3 +2,4 @@ class Dang
2
2
  end
3
3
 
4
4
  require 'dang/dang'
5
+ require 'dang/rails' if defined?(Rails)
@@ -3,7 +3,8 @@ require 'rubygems'
3
3
  require 'dang/parser'
4
4
 
5
5
  class Dang
6
- VERSION = '1.0.0.rc3'
6
+ VERSION = '1.0.0.rc4'
7
+ CODENAME = 'Zoe'
7
8
 
8
9
  @filters = {}
9
10
 
@@ -391,7 +391,7 @@ class Dang::Parser
391
391
  DOC_TYPES[@doctype].dup
392
392
  end
393
393
 
394
- def output(env=nil)
394
+ def compile
395
395
  doctype = html_doctype
396
396
 
397
397
  strings = @output.flatten.map do |i|
@@ -409,9 +409,11 @@ class Dang::Parser
409
409
  end
410
410
  end
411
411
 
412
- code = "_out = '';\n" + strings.join(";") + ";_out"
412
+ "_out = '';\n" + strings.join(";") + ";_out"
413
+ end
413
414
 
414
- out = eval(code, env || binding).strip
415
+ def output(env=nil)
416
+ out = eval(compile, env || binding).strip
415
417
 
416
418
  if doctype.empty?
417
419
  str = out
@@ -0,0 +1,49 @@
1
+ class Dang
2
+ class View
3
+ def handles_encoding?
4
+ true
5
+ end
6
+
7
+ def valid_encoding(string, encoding)
8
+ # If a magic encoding comment was found, tag the
9
+ # String with this encoding. This is for a case
10
+ # where the original String was assumed to be,
11
+ # for instance, UTF-8, but a magic comment
12
+ # proved otherwise
13
+ string.force_encoding(encoding) if encoding
14
+
15
+ # If the String is valid, return the encoding we found
16
+ return string.encoding if string.valid_encoding?
17
+
18
+ # Otherwise, raise an exception
19
+ raise ActionView::WrongEncodingError.new(string, string.encoding)
20
+ end
21
+
22
+ ENCODING_TAG = Regexp.new("\\A(<-\\s*#{ActionView::ENCODING_FLAG}\\s*->)[ \\t]*")
23
+
24
+ def call(template)
25
+ template_source = template.source.dup.force_encoding(Encoding::ASCII_8BIT)
26
+
27
+ dang = template_source.gsub(ENCODING_TAG, '')
28
+ encoding = $2
29
+
30
+ dang.force_encoding valid_encoding(template.source.dup, encoding)
31
+
32
+ # Always make sure we return a String in the default_internal
33
+ dang.encode!
34
+
35
+ puts "== Compiling #{dang}"
36
+
37
+ parser = Dang::Parser.new(dang, true)
38
+ unless parser.parse
39
+ io = StringIO.new
40
+ parser.show_error(io)
41
+ raise io.string
42
+ end
43
+
44
+ parser.compile
45
+ end
46
+ end
47
+
48
+ ActionView::Template.register_template_handler :dang, View.new
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dang
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc3
4
+ version: 1.0.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Becker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2013-06-20 00:00:00 Z
12
+ date: 2013-08-09 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: "4.0"
21
+ version: "3.10"
22
22
  type: :development
23
23
  version_requirements: *id001
24
24
  - !ruby/object:Gem::Dependency
@@ -28,10 +28,13 @@ dependencies:
28
28
  requirements:
29
29
  - - ~>
30
30
  - !ruby/object:Gem::Version
31
- version: "3.6"
31
+ version: "3.5"
32
32
  type: :development
33
33
  version_requirements: *id002
34
- description: Another dang templating language.
34
+ description: |-
35
+ Dang is a Ruby templating language
36
+ It uses angle brackets and CSS syntax.
37
+ Somewhere between ERB and Haml.
35
38
  email:
36
39
  - veganstraightedge@gmail.com
37
40
  executables:
@@ -39,12 +42,12 @@ executables:
39
42
  extensions: []
40
43
 
41
44
  extra_rdoc_files:
42
- - History.md
43
45
  - Manifest.txt
44
- - README.md
45
- - TODO.md
46
46
  files:
47
47
  - .autotest
48
+ - .gitignore
49
+ - .hoeignore
50
+ - .travis.yml
48
51
  - Gemfile
49
52
  - Gemfile.lock
50
53
  - History.md
@@ -53,13 +56,16 @@ files:
53
56
  - Rakefile
54
57
  - TODO.md
55
58
  - bin/dang
59
+ - dang.gemspec
56
60
  - lib/dang.rb
57
61
  - lib/dang/dang.rb
58
62
  - lib/dang/parser.kpeg
59
63
  - lib/dang/parser.rb
64
+ - lib/dang/rails.rb
60
65
  homepage: https://github.com/veganstraightedge/dang
61
- licenses: []
62
-
66
+ licenses:
67
+ - PUBLIC DOMAIN
68
+ - CC0
63
69
  metadata: {}
64
70
 
65
71
  post_install_message:
@@ -84,6 +90,6 @@ rubyforge_project: dang
84
90
  rubygems_version: 2.0.3
85
91
  signing_key:
86
92
  specification_version: 4
87
- summary: Another dang templating language.
93
+ summary: Dang is a Ruby templating language It uses angle brackets and CSS syntax
88
94
  test_files: []
89
95