markus 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +69 -7
  3. data/markus.gemspec +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b56f8dae30d1a2ddac59f1d7e36550689ded2406
4
- data.tar.gz: c16b86048910cb452b841c03f6554691a32f4ea1
3
+ metadata.gz: 57c28ac410d72c1221d6fa228e2be6ac5e5f3f0b
4
+ data.tar.gz: fd2e2836a0e6cdf937f662844e6ff5b7df770885
5
5
  SHA512:
6
- metadata.gz: 42040457da45fdf61b94ec9ffc9813db3222702fa0f7a41d2dfd77fbdb6c34754f53442618ab3282439ede0b41c1fcec31cc69151df09c12dee816b809252b6d
7
- data.tar.gz: f1b03b54f3b4116f702d6eab99919a5a65495766d5da67abba1d8cd99b527a49e27d81937bffcdc7898577fb4a69179b0bb59adc3c88e93aa65d19faba9aa149
6
+ metadata.gz: 757040ac2a15bb434a8f0d5be83ff576069340947ebd7a565cc38af3745b99570f2b22e3a65fa77ccdd3b0867eeca3150a93ee32ab3f5acb4ef6608f03e06a63
7
+ data.tar.gz: 1dd4d8bc8250c282b9adb15ee7c5294636ba1a6951855087e9160df9a8c6320c75ca4f42f17dd2a92efee0af461532980fa1965e20da090acaf6b7ef0bceb4ba
data/README.md CHANGED
@@ -1,19 +1,74 @@
1
1
  # Markup UnderScore
2
2
 
3
- Copyright (C) 2004-2016 Jürgen Mangler <juergen.mangler@univie.ac.at>
3
+ Copyright (C) 2004-2016 Jürgen "eTM" Mangler <juergen.mangler@gmail.com>
4
4
 
5
5
  MarkUS is freely distributable according to the terms of the
6
- GNU Lesser General Public License (see the file 'COPYING').
6
+ GNU Lesser General Public License 3.0 (see the file 'COPYING').
7
7
 
8
- This program is distributed without any warranty. See the file
8
+ This code is distributed without any warranty. See the file
9
9
  'COPYING' for details.
10
10
 
11
11
  ## Introduction
12
12
 
13
- All template libraries suck. But sometimes they are useful, for building
14
- quick'n dirty creation of documents. This template library will of course suck
13
+ All template libraries suck. But sometimes they are useful, for
14
+ quick n' dirty building of documents. This template library will of course suck
15
15
  as well. It is inspired by _why's markaby. It supports JSON and XML.
16
16
 
17
+ ## Usage - Jump Start
18
+
19
+ Its fairly simple:
20
+
21
+ 1. Create classes that inherit from MarkUS, and add templates with a name to them (see below).
22
+ 2. In the templates use arbitrary code, mixed with functions that have an _ at the end.
23
+ 3. Everything with an _ at the end is added to the result buffer
24
+ - If the first parameter is a String or Integer it will be used as content of the element
25
+ - If any parameter is a Hash it will be used as attributes in XML, or you-know-what in JSON
26
+ - If any parameter is an Array it will be used as you-know-what in JSON
27
+ - If it has a block, a nested data structure is implied (see template examples below)
28
+ - JSON only: by default a Hash is assumed, if you pass a paramter ```array```, e.g. ```value_ do |array| ... end```, the result is ```"value": [ ... ]```
29
+ - ```#template_!``` is a special method to include other templates
30
+ - ```#element_!``` allows you to include stuff in your result that is not a valid ruby function name (e.g. with a dot in the name - see below)
31
+ 4. Get the result by instantiating the class and calling one of ```#json_!```, ```#xml_!```, ```#html_!```
32
+ - ```#xml_!``` and ```#html_!``` differ in the way elements with no content are printed. XML uses short-handed tags, HTML doesn't.
33
+
34
+ ## Usage - Example
35
+
36
+ template1.rb:
37
+ ```
38
+ class Common < MarkUS
39
+ template :test1 do
40
+ query_ [2, 3, "world"]
41
+ end
42
+ template :test2 do
43
+ query_ :a => 2, :b => "hello"
44
+ end
45
+ end
46
+ ```
47
+
48
+ template2.rb:
49
+ ```
50
+ require File.expand_path(File.dirname(__FILE__) + '/template1')
51
+ class Something < MarkUS
52
+ templates Common
53
+
54
+ indent
55
+
56
+ template :main do
57
+ template_! :test1
58
+ template_! :test2
59
+ end
60
+ end
61
+ ```
62
+
63
+ main.rb:
64
+ ```
65
+ require File.expand_path(File.dirname(__FILE__) + '/template2')
66
+ s = Something.new
67
+ result = s.json_! :main
68
+ ```
69
+
70
+ If you add ```reload``` to any of the template classes, they will be reloaded if they change (if templates are use in a long-running service).
71
+
17
72
  ## HTML Example Template
18
73
 
19
74
  ```
@@ -59,6 +114,13 @@ knows.
59
114
 
60
115
  * You need a least ruby 1.9.2
61
116
 
62
- ## Documentation
117
+ ## Further Reading
118
+
119
+ View the example in the ./examples subdirectory. View the tests in the ./test subdirectory. From there you should be able to figure it out yourself. Tip: neat combinations with heredocs are possible, e.g. to create script tags in html.
120
+
121
+ ```
122
+ script_ <<~end
123
+ var foo = "bar";
124
+ end
125
+ ```
63
126
 
64
- View the examples in the ./examples subdirectory.
data/markus.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "markus"
3
- s.version = "4.0.2"
3
+ s.version = "4.0.3"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3"
6
6
  s.summary = "MarkUS - Markup UnderScore. Quick n' dirty templating in the spirit of markaby."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markus
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler