markaby 0.8.1 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aed95364f1421acaab2191897e35fb1a278051cd
4
- data.tar.gz: 605b3d61e47bdc08256f2034fd5717ab080585f7
2
+ SHA256:
3
+ metadata.gz: 535329bcc48d16625bfba60bf91d25e9fc40f44821057beeea32b4e49d7271b8
4
+ data.tar.gz: 30e7730d1d4b8c3b7997c9956dda022cd4851cbf16f7a124c4cb1df62eb5b255
5
5
  SHA512:
6
- metadata.gz: 93daf68ab25910cffadcd442f9dd0e05d9e2afb245f16f308776e27e0876d54a9068624d065cf52f03798925aafb4626c14f7ef51d7970d038f4c9a8a2c6e778
7
- data.tar.gz: 824f9a360031c25711dadad5bd32a0f84ec12533c2d88bcb57835a9c8ef32804a7a097a338987f48e2c2bd46e029c5830d5195d0fb754a87248cc0bcf55a5e50
6
+ metadata.gz: 53e7e2a1b89c5c0bfb2e3758a0f3a3235c7b68539787e7722bc862124b52ac28bab464479e2fc605415616b187251dd69d5e6ee38f64fce20186139a782c9c47
7
+ data.tar.gz: c105c5c0d893354d6069c9e18d8694a80673bf97f24ee24ec8c41c99c9c86432362ac51f0d8f7d61d8db423a726a77a6796c51e87552e7859d940faef154e8b7
data/.gitignore CHANGED
@@ -18,4 +18,5 @@ rdoc
18
18
  spec/reports
19
19
  test/tmp
20
20
  test/version_tmp
21
- tmp
21
+ tmp
22
+ .byebug_history
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.1
1
+ ruby-2.7.3
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 2.4
5
+ - 2.5
6
+ - 2.6
7
+ - 2.7
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: jruby-9.1.15.0
11
+ - rvm: rbx-2
12
+ install: bundle install --without=development --jobs=3 --retry=3
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,22 @@
1
+ = HEAD
2
+
3
+ = 0.9.1
4
+
5
+ * update release tasks [tech task]
6
+ * re-release version since code was included in last release
7
+
8
+ = 0.9.0
9
+
10
+ * Add data attributes: https://github.com/markaby/markaby/pull/44 (rahoulb)
11
+
12
+ * Add data + aria attributes
13
+ * Allow creation of custom web components / elements in html5
14
+ my_custom_element prop: "value" =>
15
+ "<my-custom-element prop="value"></my-custom-element>"
16
+ See https://stackoverflow.com/questions/9845011/are-custom-elements-valid-html5
17
+ * split up tag sets into different files
18
+ * add standardrb + use code conventions
19
+
1
20
  = 0.7.1 (2010-08-19)
2
21
 
3
22
  * Rails fixes for form_for called from erb templates
data/Gemfile CHANGED
@@ -1,8 +1,14 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'builder'
3
+ gem "builder"
4
+
5
+ group :development do
6
+ gem "standardrb"
7
+ end
4
8
 
5
9
  group :test do
6
- gem 'rake'
7
- gem 'rspec'
8
- end
10
+ gem "rake"
11
+ gem "rspec"
12
+ gem "test-unit"
13
+ gem "byebug"
14
+ end
data/Gemfile.lock CHANGED
@@ -1,22 +1,79 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- builder (3.2.2)
5
- diff-lcs (1.2.5)
6
- rake (10.1.0)
7
- rspec (2.14.1)
8
- rspec-core (~> 2.14.0)
9
- rspec-expectations (~> 2.14.0)
10
- rspec-mocks (~> 2.14.0)
11
- rspec-core (2.14.7)
12
- rspec-expectations (2.14.4)
13
- diff-lcs (>= 1.1.3, < 2.0)
14
- rspec-mocks (2.14.4)
4
+ ast (2.4.2)
5
+ builder (3.2.4)
6
+ byebug (11.1.3)
7
+ diff-lcs (1.5.0)
8
+ json (2.6.3)
9
+ language_server-protocol (3.17.0.3)
10
+ lint_roller (1.0.0)
11
+ parallel (1.23.0)
12
+ parser (3.2.2.1)
13
+ ast (~> 2.4.1)
14
+ power_assert (2.0.3)
15
+ rainbow (3.1.1)
16
+ rake (13.0.6)
17
+ regexp_parser (2.8.0)
18
+ rexml (3.2.5)
19
+ rspec (3.12.0)
20
+ rspec-core (~> 3.12.0)
21
+ rspec-expectations (~> 3.12.0)
22
+ rspec-mocks (~> 3.12.0)
23
+ rspec-core (3.12.2)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-expectations (3.12.3)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-mocks (3.12.5)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-support (3.12.0)
32
+ rubocop (1.50.2)
33
+ json (~> 2.3)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.2.0.0)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml (>= 3.2.5, < 4.0)
39
+ rubocop-ast (>= 1.28.0, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 2.4.0, < 3.0)
42
+ rubocop-ast (1.28.1)
43
+ parser (>= 3.2.1.0)
44
+ rubocop-performance (1.16.0)
45
+ rubocop (>= 1.7.0, < 2.0)
46
+ rubocop-ast (>= 0.4.0)
47
+ ruby-progressbar (1.13.0)
48
+ standard (1.28.2)
49
+ language_server-protocol (~> 3.17.0.2)
50
+ lint_roller (~> 1.0)
51
+ rubocop (~> 1.50.2)
52
+ standard-custom (~> 1.0.0)
53
+ standard-performance (~> 1.0.1)
54
+ standard-custom (1.0.0)
55
+ lint_roller (~> 1.0)
56
+ standard-performance (1.0.1)
57
+ lint_roller (~> 1.0)
58
+ rubocop-performance (~> 1.16.0)
59
+ standardrb (1.0.1)
60
+ standard
61
+ test-unit (3.5.8)
62
+ power_assert
63
+ unicode-display_width (2.4.2)
15
64
 
16
65
  PLATFORMS
66
+ arm64-darwin-22
17
67
  ruby
68
+ x86_64-darwin-17
18
69
 
19
70
  DEPENDENCIES
20
71
  builder
72
+ byebug
21
73
  rake
22
74
  rspec
75
+ standardrb
76
+ test-unit
77
+
78
+ BUNDLED WITH
79
+ 2.4.13
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2006-2018 markaby group (Scott Taylor (smtlaissezfaire), Jonathan Gillette (_why), and related maintainers)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/Markaby.gemspec CHANGED
@@ -1,24 +1,20 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'markaby/version'
1
+ require_relative "lib/markaby/version"
5
2
 
6
3
  Gem::Specification.new do |spec|
7
- spec.name = "markaby"
8
- spec.version = Markaby::VERSION
9
- spec.authors = ["Scott Taylor", "judofyr", "_why"]
10
- spec.email = ["scott@railsnewbie.com"]
11
- spec.description = "_why's markaby templating language"
12
- spec.summary = "A pure ruby based, html markup language"
13
- spec.homepage = ""
14
- spec.license = "MIT"
4
+ spec.name = "markaby"
5
+ spec.version = Markaby::VERSION
6
+ spec.authors = ["Scott Taylor", "judofyr", "_why"]
7
+ spec.email = ["scott@railsnewbie.com"]
8
+ spec.description = "_why's markaby templating language"
9
+ spec.summary = "A pure ruby based, html markup language"
10
+ spec.homepage = ""
11
+ spec.license = "MIT"
15
12
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
15
  spec.require_paths = ["lib"]
20
16
 
21
17
  spec.add_dependency "builder"
22
- spec.add_development_dependency "bundler", "~> 1.3"
18
+ spec.add_development_dependency "bundler", ">= 2.2.10"
23
19
  spec.add_development_dependency "rake"
24
20
  end
data/README.rdoc CHANGED
@@ -5,35 +5,79 @@ It is an alternative to ERb which weaves the two languages together.
5
5
  Also a replacement for templating languages which use primitive languages
6
6
  that blend with HTML.
7
7
 
8
- === Install it as a gem
8
+ == Install it
9
9
 
10
- gem install markaby
10
+ Just do what everyone else does:
11
11
 
12
- == Using Markaby with Sinatra (1.0+)
12
+ # in Gemfile:
13
+ gem 'markaby', '>= 0.9'
13
14
 
14
- get '/foo' do
15
- mab :my_template # my_template.mab in the sinatra view path
16
- end
15
+ then bundle install:
17
16
 
18
- If you are looking for sinatra support pre 0.7, see http://github.com/sbfaulkner/sinatra-markaby
17
+ bundle install
18
+
19
+ === Using Markaby with Rails 4/5+:
20
+
21
+ Install the gem (using bundler), then:
22
+
23
+ # in config/initializers/markaby.rb:
24
+
25
+ require 'markaby/rails'
26
+
27
+ Markaby::Rails::TemplateHandler.register!({
28
+ tagset: Markaby::HTML5,
29
+ indent: 2,
30
+ })
31
+
32
+ Name your templates with an html.mab extension. You'll also want to configure
33
+ your text editor to see .mab as ruby.
34
+
35
+ Here's how you'd do that for Atom:
36
+
37
+ 1. Install the file-types module:
38
+
39
+ apm install file-types
40
+
41
+ 1. in your config: Atom -> Config:
42
+
43
+ "*":
44
+ "file-types":
45
+ "\\.mab$": "source.ruby"
46
+
47
+ Now that's some chunky bacon!
19
48
 
20
- A note on Tilt - using markaby with html5 doesn't quite yet work properly. If you'd like to render a template with html 5, call this at the start of a .mab template:
49
+ === Using Markaby in helpers:
21
50
 
22
- enable_html5!
51
+ Just call Markaby::Builder with a block as below.
23
52
 
24
- Or enable html 5 globally:
53
+ You can also require 'markaby/kernel_method' to make it even easier:
25
54
 
26
- Markaby::Builder.class_eval do
27
- @@options = Markaby::Builder::HTML5_OPTIONS
28
- end
55
+ # my_helper.rb:
56
+ require 'markaby/kernel_method' # or put this in an initializer
29
57
 
30
- == Using Markaby with other frameworks
58
+ module MyHelper
59
+ # note - you can also use Markaby::Builder.new { }.to_s
60
+ def chunky_bacon
61
+ mab do
62
+ p "Chunky Bacon!"
63
+ end
64
+ end
65
+ end
66
+
67
+ === Using Markaby with Sinatra (1.0+)
68
+
69
+ get '/foo' do
70
+ mab :my_template # my_template.mab in the sinatra view path
71
+ end
72
+
73
+ If you are looking for sinatra support pre 0.7, see http://github.com/sbfaulkner/sinatra-markaby
74
+
75
+ === Using Markaby with other frameworks
31
76
 
32
77
  Tilt has a Markaby module, so in principle, any web framework that supports
33
78
  Tilt will also support Markaby. See the appropriate tilt documentation:
34
79
 
35
- http://github.com/rtomayko/tilt
36
-
80
+ http://github.com/rtomayko/tilt
37
81
 
38
82
  == Using Markaby as a Ruby class
39
83
 
@@ -110,15 +154,17 @@ Which results in:
110
154
  <div class="entryContent">Okay, once again, the idea here is ...</div>
111
155
  </div>
112
156
 
157
+ Alternatively you can define the class as an attribute on your element - see below.
158
+
113
159
  == 2. Element IDs
114
160
 
115
161
  IDs may be added by the use of bang methods:
116
162
 
117
- div.page! {
118
- div.content! {
163
+ div.page! do
164
+ div.content! do
119
165
  h1 "A Short Short Saintly Dog"
120
- }
121
- }
166
+ end
167
+ end
122
168
 
123
169
  Which results in:
124
170
 
@@ -128,6 +174,8 @@ Which results in:
128
174
  </div>
129
175
  </div>
130
176
 
177
+ Alternatively you can define the ID as an attribute on your element - see below.
178
+
131
179
  == 3. Validate Your XHTML 1.0 Output
132
180
 
133
181
  If you'd like Markaby to help you assemble valid XHTML documents,
@@ -146,8 +194,8 @@ tag.
146
194
  Now, since Markaby knows which doctype you're using, it checks a big
147
195
  list of valid tags and attributes before printing anything.
148
196
 
149
- >> div :styl => "padding: 10px" do
150
- >> img :src => "samorost.jpg"
197
+ >> div styl: "padding: 10px" do
198
+ >> img src: "samorost.jpg"
151
199
  >> end
152
200
  InvalidHtmlError: no such attribute `styl'
153
201
 
@@ -173,11 +221,11 @@ as an argument:
173
221
  One caveat: if you have other tags inside a block, the string
174
222
  passed back will be ignored.
175
223
 
176
- div.comment {
224
+ div.comment do
177
225
  div.author "_why"
178
226
  div.says "Torpedoooooes!"
179
227
  "<div>Silence.</div>"
180
- }
228
+ end
181
229
 
182
230
  The final div above won't appear in the output. You can't mix
183
231
  tag modes like that, friend.
@@ -220,11 +268,81 @@ won't work with this technique.
220
268
  end
221
269
  end
222
270
 
271
+ If you wish to register your own, specialist, tags, you can install a TagHandler
272
+
273
+ == Some other notes, so you aren't confused:
274
+
275
+ === On using different tagsets:
276
+
277
+ Because of the ways various frameworks sub-render templates, to use a different
278
+ tagset in a rendered sub template, you may need to set it at the top of your
279
+ sub-template:
280
+
281
+ self.tagset = Markaby::HTML5
282
+ # or Markaby::Transitional, Markaby::XHTMLStrict, Markaby::XHTMLFrameset
283
+
284
+ Note, this is only necessary if you were rendering, say, a one off page as
285
+ html transitional but had the default engine as html5.
286
+
287
+ === Defining attributes on elements
288
+
289
+ If you do not use the <tt>CssProxy</tt> (<tt>div.entry</tt> to define the class, <tt>div.page!</tt> to define the ID), then you can pass a hash to your element to define any arbitrary attributes.
290
+
291
+ div id: "page-123", class: "entry" do
292
+ div style: "display: inline-block;" do
293
+ p "Have you noticed this book is basically written by a lunatic?"
294
+ end
295
+ end
296
+
297
+ Will result in
298
+
299
+ <div id="page-123" class="entry">
300
+ <div style="display: inline-block;">
301
+ <p>Have you noticed this book is basically written by a lunatic?</p>
302
+ </div>
303
+ </div>
304
+
305
+ If you pass a hash to your attribute definition, Markaby will expand the hash entries. This is useful for data attributes (for example, if you are using a Stimulus controller), or aria attributes. Any attributes will have underscores replaced with dashes when the hash is expanded.
306
+
307
+ div data: { controller: "something" } do
308
+ div do
309
+ h1(data: { something_target: "title" }) { "There goes my pickup" }
310
+ end
311
+ end
312
+
313
+ Will result in
314
+
315
+ <div data-controller="something">
316
+ <div>
317
+ <h1 data-something-target="title">There goes my pickup</h1>
318
+ </div>
319
+ </div>
320
+
321
+ === Custom elements and web components
322
+
323
+ If you are using the HTML5 tagset (which is the default), and your document has custom-elements defined, you can create those in the same way as standard elements.
324
+
325
+ Unlike standard elements, there is no validity checking for your attributes.
326
+
327
+ article do
328
+ my_custom_panel variant: "primary" do
329
+ p "Our careers are so over"
330
+ end
331
+ end
332
+
333
+ Results in
334
+
335
+ <article>
336
+ <my-custom-panel variant="primary">
337
+ <p>Our careers are so over</p>
338
+ </my-custom-panel>
339
+ </article>
340
+
223
341
  = Credits
224
342
 
225
343
  Markaby is a work of immense hope by Tim Fletcher and why the lucky stiff.
226
344
  It is maintained by joho, spox, and smtlaissezfaire.
227
- Thankyou for giving it a whirl.
345
+ Thank you for giving it a whirl.
228
346
 
229
347
  Markaby is inspired by the HTML library within cgi.rb. Hopefully it will
230
348
  turn around and take some cues.
data/Rakefile CHANGED
@@ -1,25 +1,25 @@
1
- require 'rake'
1
+ require "rake"
2
2
  require "bundler/gem_tasks"
3
- require 'rspec/core/rake_task'
4
- require 'rake/clean'
3
+ require "rspec/core/rake_task"
4
+ require "rake/clean"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
- task :default => :spec
7
+ task default: :spec
8
8
 
9
9
  Bundler::GemHelper.install_tasks
10
10
 
11
11
  desc "List any Markaby specific warnings"
12
12
  task :warnings do
13
- `ruby -w test/test_markaby.rb 2>&1`.split(/\n/).each do |line|
14
- next unless line =~ /warning:/
15
- next if line =~ /builder-/
13
+ `ruby -w test/test_markaby.rb 2>&1`.split("\n").each do |line|
14
+ next unless /warning:/.match?(line)
15
+ next if /builder-/.match?(line)
16
16
  puts line
17
17
  end
18
18
  end
19
19
 
20
20
  desc "Start a Markaby-aware IRB session"
21
21
  task :irb do
22
- sh 'irb -I lib -r markaby -r markaby/kernel_method'
22
+ sh "irb -I lib -r markaby -r markaby/kernel_method"
23
23
  end
24
24
 
25
25
  namespace :gemspec do
@@ -29,19 +29,25 @@ namespace :gemspec do
29
29
  end
30
30
  end
31
31
 
32
- # namespace :release do
33
- # task :patch => [:spec, "version:bump:patch", :update_gemspec, :rerdoc, :tag_release, :build, :push_tags]
34
- #
35
- # task :update_gemspec => ["gemspec:generate", "gemspec:validate", "gemspec:commit"]
36
- # task :tag_release do
37
- # require File.dirname(__FILE__) + "/lib/markaby"
38
- # version = "v#{Markaby::VERSION}"
39
- # sh "git tag #{version}"
40
- # end
41
- #
42
- # task :push_tags do
43
- # sh "git push --tags"
44
- # end
45
- # end
46
- #
47
- # task :release => "release:patch"
32
+ namespace :release do
33
+ # make sure to bump version + update changelogs in lib/markaby/version.rb before running
34
+ task :patch => [:spec, :update_gemspec, :tag_release, :build, :push_tags]
35
+
36
+ task :update_gemspec => ["gemspec:commit"]
37
+
38
+ task :tag_release do
39
+ require File.dirname(__FILE__) + "/lib/markaby"
40
+ version = "v#{Markaby::VERSION}"
41
+ sh "git tag #{version}"
42
+ end
43
+
44
+ task :push_tags do
45
+ sh "git push --tags"
46
+ end
47
+
48
+ task :push_gem do
49
+ sh "gem push pkg/markaby-#{Markaby::VERSION}.gem"
50
+ end
51
+ end
52
+
53
+ task :release => "release:patch"