papercraft 0.29 → 1.0

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
  SHA256:
3
- metadata.gz: 1ca707074311c909d6e2b4aa86748f1ffbd5b614d73fb78e85985d174b69e263
4
- data.tar.gz: f53dc4fa5088472ccc805f50938f25539950446fe14e97facb2cc346722d13fe
3
+ metadata.gz: d769e6ec71d8c6d60ebb0aa727037b691562a31ec1fc1a05ccb0f25f29858b7a
4
+ data.tar.gz: 97b15299e8b4ca3d801aec881bd0ea4cee245650225f9c6e41972333ab9f8011
5
5
  SHA512:
6
- metadata.gz: 0d216f2c8db4beed8c7fe184d3b8e0a13ba8af4684d4e46f5506f0b1eb6c3bfaa0ad76b7a5b1b6e28a8ba37a730545ca00139fd0bf35b74628d117c504fc1e9c
7
- data.tar.gz: 27ac04cf8b75b5d6abda511513618fb6ef20417365ac7b45855d909323db3c536204f85d719a44e2374b095d955f4eb0c25901290990dab861c908fa4d73142e
6
+ metadata.gz: ff74adc23fc616b579f9729cecc595e2eebe92d2b96b6edcceff4eae043c7ca8048e3baea14f275533667809183cd7961e14c74a6afb71b04fe7902806c8678c
7
+ data.tar.gz: 8fcecbac3baa12296ae3386ecb31eb0db0d7e001f4f38dd1c055ab497a3113471338d26cca8812582091e10c17ab5413c1e37cdf172d07ca1eac011206935d90
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0 2023-03-30
2
+
3
+ - Add support for Array attribute values
4
+
1
5
  ## 0.29 2023-03-11
2
6
 
3
7
  - Add Tilt integration (#15)
data/README.md CHANGED
@@ -84,6 +84,7 @@ hello.render('world')
84
84
  - [Emitting Markdown](#emitting-markdown)
85
85
  - [Working with MIME Types](#working-with-mime-types)
86
86
  - [Deferred Evaluation](#deferred-evaluation)
87
+ - [HTML Templates](#html-templates)
87
88
  - [XML Templates](#xml-templates)
88
89
  - [JSON Templates](#json-templates)
89
90
  - [Papercraft Extensions](#papercraft-extensions)
@@ -198,14 +199,28 @@ Papercraft.html { hr() }.render #=> "<hr/>"
198
199
  Tag methods also accept tag attributes, given as a hash:
199
200
 
200
201
  ```ruby
201
- Papercraft.html { img src: '/my.gif' }.render #=> "<img src="/my.gif"/>
202
+ Papercraft.html { img src: '/my.gif' }.render #=> "<img src=\"/my.gif\"/>"
202
203
 
203
204
  Papercraft.html { p "foobar", class: 'important' }.render #=> "<p class=\"important\">foobar</p>"
204
205
  ```
205
206
 
207
+ A `true` attribute value will emit a valueless attribute. A `nil` or `false`
208
+ attribute value will emit nothing:
209
+
210
+ ```ruby
211
+ Papercraft.html { button disabled: nil }.render #=> "<button></button>"
212
+ Papercraft.html { button disabled: true }.render #=> "<button disabled></button>"
213
+ ```
214
+
215
+ An attribute value given as an array will be joined by space characters:
216
+
217
+ ```ruby
218
+ Papercraft.html { div class: [:foo, :bar] }.render #=> "<div class=\"foo bar\"></div>"
219
+ ```
220
+
206
221
  ## Tag and Attribute Formatting
207
222
 
208
- Papercraft does not make any presumption about what tags and attributes you can
223
+ Papercraft does not make any assumption about what tags and attributes you can
209
224
  use. You can mix upper and lower case letters, and you can include arbitrary
210
225
  characters in tag and attribute names. However, in order to best adhere to the
211
226
  HTML and XML specs and common practices, tag names and attributes will be
@@ -276,7 +291,7 @@ greeting.render(name: 'world') #=> "<h1>Hello, world!</h1>"
276
291
 
277
292
  ## Template Logic
278
293
 
279
- Since Papercraft templates are just a bunch of Ruby, you can easily write your
294
+ Since Papercraft templates are just a bunch of Ruby, you can easily embed your
280
295
  view logic right in the template:
281
296
 
282
297
  ```ruby
@@ -585,6 +600,24 @@ page = default_layout.apply {
585
600
  }
586
601
  ```
587
602
 
603
+ ## HTML Templates
604
+
605
+ HTML templates include a few HTML-specific methods to facilitate writing modern
606
+ HTML:
607
+
608
+ - `html5 { ... }` - emits an HTML 5 DOCTYPE (`<!DOCTYPE html>`)
609
+ - `import_map(root_path, root_url)` - emits an import map including all files
610
+ matching `<root_path>/*.js`, based on the given `root_url`
611
+ - `js_module(js)` - emits a `<script type="module">` element
612
+ - `link_stylesheet(href, **attributes)` - emits a `<link rel="stylesheet" ...>`
613
+ element
614
+ - `script(js, **attributes)` - emits an inline `<script>` element
615
+ - `style(css, **attributes)` - emits an inline `<style>` element
616
+ - `versioned_file_href(href, root_path, root_url)` - calculates a versioned href
617
+ for the given file
618
+
619
+ [HTML docs](https://www.rubydoc.info/gems/papercraft/Papercraft/HTML)
620
+
588
621
  ## XML Templates
589
622
 
590
623
  XML templates behave largely the same as HTML templates, with a few minor
@@ -620,6 +653,8 @@ rss = Papercraft.xml(mime_type: 'text/xml; charset=utf-8') { |resource:, **props
620
653
  }
621
654
  ```
622
655
 
656
+ [XML docs](https://www.rubydoc.info/gems/papercraft/Papercraft/XML)
657
+
623
658
  ## JSON Templates
624
659
 
625
660
  JSON templates behave largely the same as HTML and XML templates. The only major
@@ -651,6 +686,8 @@ Papercraft.json {
651
686
  Papercraft uses the [JSON gem](https://rubyapi.org/3.1/o/json) under the hood in
652
687
  order to generate actual JSON.
653
688
 
689
+ [JSON docs](https://www.rubydoc.info/gems/papercraft/Papercraft/JSON)
690
+
654
691
  ## Papercraft Extensions
655
692
 
656
693
  Papercraft extensions are modules that contain one or more methods that can be
@@ -857,6 +894,8 @@ xml = Papercraft.xml {
857
894
  }
858
895
  ```
859
896
 
897
+ [SOAP docs](https://www.rubydoc.info/gems/papercraft/Papercraft/Extensions/Soap)
898
+
860
899
  ## API Reference
861
900
 
862
901
  The API reference for this library can be found
@@ -387,6 +387,10 @@ module Papercraft
387
387
  @buffer << S_SPACE << att_repr(k)
388
388
  when false, nil
389
389
  # emit nothing
390
+ when Array
391
+ v = v.join(' ')
392
+ @buffer << S_SPACE << att_repr(k) <<
393
+ S_EQUAL_QUOTE << escape_text(v) << S_QUOTE
390
394
  else
391
395
  @buffer << S_SPACE << att_repr(k) <<
392
396
  S_EQUAL_QUOTE << escape_text(v) << S_QUOTE
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Papercraft
4
- VERSION = '0.29'
4
+ VERSION = '1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papercraft
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.29'
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-11 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: escape_utils