template_tags 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a1ae011154bf371857d6c887bd51a78cbfdfd9c
4
+ data.tar.gz: a07d4f5fd84bd5b4a16083f83ff4b43d2657d187
5
+ SHA512:
6
+ metadata.gz: 8b82ab0bdd2a203fef7c47de3771413cfc0c1115c40c13ec5e3744966a5a3c01cbb8f0aa74555b857f49bbc923dd3b957447f50790eb19696f6612c9ff822be0
7
+ data.tar.gz: 443fe05d799f37610fab39f8a43d0bc8bd10c52901f5d0aa531c953a8dcb0b1648ecb77728a09154c9f318e39c55860089c9698c91c05ecee591187bdc9aa158
data/.editorconfig ADDED
@@ -0,0 +1,11 @@
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ indent_style = space
7
+ indent_size = 2
8
+ end_of_line = lf
9
+ charset = utf-8
10
+ trim_trailing_whitespace = true
11
+ insert_final_newline = true
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /spec/internal/log
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,33 @@
1
+ language: ruby
2
+ cache: bundler
3
+ script: bundle exec rspec
4
+ before_install: gem install bundler -v 1.10.6
5
+ rvm:
6
+ - 1.9.3
7
+ - "2.0"
8
+ - "2.1"
9
+ - "2.2"
10
+ - ruby-2.3.0-preview1
11
+ - rbx-2
12
+ - jruby-19mode
13
+ - ruby-head
14
+ - jruby-head
15
+
16
+ gemfile:
17
+ - gemfiles/Rails-4.2.gemfile
18
+
19
+ matrix:
20
+ include:
21
+ - rvm: "2.2"
22
+ gemfile: gemfiles/Rails-4.1.gemfile
23
+
24
+ - rvm: "2.2"
25
+ gemfile: gemfiles/Rails-4.0.gemfile
26
+
27
+ - rvm: "2.2"
28
+ gemfile: gemfiles/Rails-head.gemfile
29
+
30
+ allow_failures:
31
+ - rvm: ruby-head
32
+ - rvm: jruby-head
33
+ - gemfile: gemfiles/Rails-head.gemfile
data/COPYING-ISC ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2015 Sebastian Skałacki
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose
4
+ with or without fee is hereby granted, provided that the above copyright notice
5
+ and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12
+ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
13
+ OR PERFORMANCE OF THIS SOFTWARE.
data/COPYING-MIT ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Sebastian Skałacki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/COPYING-RUBY ADDED
@@ -0,0 +1,59 @@
1
+ This is copyrighted free software
2
+ by Sebastian Skałacki <skalee@gmail.com>.
3
+
4
+ You can redistribute it and/or modify it under either the terms of the Expat
5
+ license (see COPYING-MIT file), or ISC license (see COPYING-ISC file),
6
+ or the conditions below:
7
+
8
+ 1. You may make and give away verbatim copies of the source form of the
9
+ software without restriction, provided that you duplicate all of the
10
+ original copyright notices and associated disclaimers.
11
+
12
+ 2. You may modify your copy of the software in any way, provided that
13
+ you do at least ONE of the following:
14
+
15
+ a) place your modifications in the Public Domain or otherwise
16
+ make them Freely Available, such as by posting said
17
+ modifications to Usenet or an equivalent medium, or by allowing
18
+ the author to include your modifications in the software.
19
+
20
+ b) use the modified software only within your corporation or
21
+ organization.
22
+
23
+ c) give non-standard binaries non-standard names, with
24
+ instructions on where to get the original software distribution.
25
+
26
+ d) make other distribution arrangements with the author.
27
+
28
+ 3. You may distribute the software in object code or binary form,
29
+ provided that you do at least ONE of the following:
30
+
31
+ a) distribute the binaries and library files of the software,
32
+ together with instructions (in the manual page or equivalent)
33
+ on where to get the original distribution.
34
+
35
+ b) accompany the distribution with the machine-readable source of
36
+ the software.
37
+
38
+ c) give non-standard binaries non-standard names, with
39
+ instructions on where to get the original software distribution.
40
+
41
+ d) make other distribution arrangements with the author.
42
+
43
+ 4. You may modify and include the part of the software into any other
44
+ software (possibly commercial). But some files in the distribution
45
+ are not written by the author, so that they are not under these terms.
46
+
47
+ For the list of those files and their copying conditions, see the
48
+ file LEGAL.
49
+
50
+ 5. The scripts and library files supplied as input to or produced as
51
+ output from the software do not automatically fall under the
52
+ copyright of the software, but belong to whomever generated them,
53
+ and may be sold commercially, and may be aggregated with this
54
+ software.
55
+
56
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
57
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
58
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59
+ PURPOSE.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in template_tags.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard :rspec, cmd: "bundle exec rspec --color" do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { "spec" }
4
+ watch("spec/spec_helper.rb") { "spec" }
5
+ watch(%r{\.gemspec$}) { "spec" }
6
+ end
data/README.adoc ADDED
@@ -0,0 +1,121 @@
1
+ TemplateTags
2
+ ============
3
+ :homepage: https://github.com/skalee/template_tags
4
+ :toc:
5
+
6
+ image:https://img.shields.io/gem/v/template_tags.svg[
7
+ Version, link="https://rubygems.org/gems/template_tags"]
8
+ image:https://img.shields.io/travis/skalee/template_tags/master.svg[
9
+ Build Status, link="https://travis-ci.org/skalee/template_tags"]
10
+
11
+ There are several ways to provide client-side templates. One possibility is to
12
+ put them inside +<script>+ elements.
13
+
14
+ Unfortunately, many text editors interpret all such content as JavaScript
15
+ and enable unwanted syntax highlight mode. However, this can be remedied by
16
+ using a dedicated helper method. I found myself copying that helper method
17
+ into several projects, therefore I decided to extract it into a gem.
18
+
19
+ Usage
20
+ -----
21
+
22
+ This gem provides a +#template_tag+ which renders a proper script tag. Template
23
+ can be either:
24
+
25
+ . Passed as a block:
26
+ +
27
+ [source,html]
28
+ --------------------------------------------------------------------------------
29
+ <%= template_tag "simple-tpl" do %>
30
+ <div id="div-with-link">
31
+ <%= link_to "Example", "http://example.test" %>
32
+ </div>
33
+ <% end %>
34
+ --------------------------------------------------------------------------------
35
+
36
+ . Indicated by passing a partial name:
37
+ +
38
+ [source,html]
39
+ --------------------------------------------------------------------------------
40
+ <%= template_tag "simple-tpl", partial: "/enclose_me",
41
+ locals: {url: "http://example.test"} %>
42
+ --------------------------------------------------------------------------------
43
+
44
+ Provided that following view partial is defined in
45
+ +/app/views/_enclose_me.html.erb+:
46
+
47
+ [source,html]
48
+ --------------------------------------------------------------------------------
49
+ <div id="div-with-link">
50
+ <%= link_to "Example", url %>
51
+ </div>
52
+ --------------------------------------------------------------------------------
53
+
54
+ Both will return the same HTML fragment:
55
+ [source,html]
56
+ --------------------------------------------------------------------------------
57
+ <script type="text/x-tmpl" id="simple-tpl">
58
+ <div id="div-with-link">
59
+ <a href="http://example.test">Example</a>
60
+ </div>
61
+ </script>
62
+ --------------------------------------------------------------------------------
63
+
64
+ Missing features
65
+ ----------------
66
+
67
+ This gem is ready for use. That said, there are several less-important features
68
+ which could be added:
69
+
70
+ . Ability to specify script element's +type+ attribute, either per use or
71
+ with single application-wide setting.
72
+ . Some ready-to-go +getTemplate()+ JavaScript function, although
73
+ +document.getElementById()+ is no rocket science.
74
+ . Ability to render HTML5's +<template>+ element, not widely supported yet.
75
+
76
+ Contributing
77
+ ------------
78
+
79
+ Bug reports and pull requests are welcome on GitHub
80
+ at https://github.com/skalee/template_tags.
81
+
82
+ When run with Guard, tests may fail randomly for some reason. Retrying always
83
+ helps. Never happens outside Guard.
84
+
85
+ Installation
86
+ ------------
87
+
88
+ Add this line to your application's Gemfile:
89
+
90
+ [source,ruby]
91
+ --------------------------------------------------------------------------------
92
+ gem 'template_tags'
93
+ --------------------------------------------------------------------------------
94
+
95
+ And then execute:
96
+
97
+ [source,sh]
98
+ --------------------------------------------------------------------------------
99
+ $ bundle
100
+ --------------------------------------------------------------------------------
101
+
102
+ Or install it yourself as:
103
+
104
+ [source,sh]
105
+ --------------------------------------------------------------------------------
106
+ $ gem install template_tags
107
+ --------------------------------------------------------------------------------
108
+
109
+ License
110
+ -------
111
+
112
+ Template Tags is licensed under either the terms of
113
+ https://tldrlegal.com/license/ruby-license-(ruby)[Ruby],
114
+ https://tldrlegal.com/license/-isc-license[ISC],
115
+ or https://tldrlegal.com/license/mit-license[MIT (Expat)] licenses.
116
+
117
+ See also
118
+ --------
119
+
120
+ * http://www.html5rocks.com/en/tutorials/webcomponents/template/[HTML's New
121
+ Template Tag] — nice _HTML5 Rocks_ article about +<template>+ tag.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "template_tags"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "railties", "~> 4.0.0"
4
+
5
+ gemspec path: ".."
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "railties", "~> 4.1.0"
4
+
5
+ gemspec path: ".."
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "railties", "~> 4.2.0"
4
+
5
+ gemspec path: ".."
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "railties", github: "rails/rails"
4
+
5
+ gemspec path: ".."
@@ -0,0 +1,10 @@
1
+ require "template_tags/version"
2
+
3
+ require "action_view/railtie"
4
+ require "action_controller/railtie"
5
+
6
+ require "template_tags/view_helper"
7
+ require "template_tags/railtie"
8
+
9
+ module TemplateTags
10
+ end
@@ -0,0 +1,9 @@
1
+ module TemplateTags
2
+
3
+ class Railtie < Rails::Railtie
4
+ initializer "template_tags.view_helper" do
5
+ ActionView::Base.send :include, ViewHelper
6
+ end
7
+ end
8
+
9
+ end
@@ -0,0 +1,3 @@
1
+ module TemplateTags
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,15 @@
1
+ module TemplateTags
2
+ module ViewHelper
3
+
4
+ def template_tag id, options = {}, &block
5
+ script_tag_options = {type: "text/x-tmpl", id: id}
6
+
7
+ if options[:partial].present?
8
+ content_tag :script, (render options), script_tag_options
9
+ else
10
+ content_tag :script, script_tag_options, &block
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "template_tags/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "template_tags"
8
+ spec.version = TemplateTags::VERSION
9
+ spec.authors = ["Sebastian Skałacki"]
10
+ spec.email = ["skalee@gmail.com"]
11
+
12
+ spec.summary = %q{Simple view helper for Rails which makes embedding} +
13
+ %q{ client-side templates in views bit easier.}
14
+ spec.licenses = %w[Ruby MIT ISC]
15
+ spec.homepage = "https://github.com/skalee/template_tags"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_runtime_dependency "railties", "~> 4.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "combustion", "~> 0.5.3"
26
+ spec.add_development_dependency "guard-rspec"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "nokogiri"
29
+ spec.add_development_dependency "rspec-rails", "~> 3.4"
30
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: template_tags
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sebastian Skałacki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: combustion
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
111
+ description:
112
+ email:
113
+ - skalee@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".editorconfig"
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - COPYING-ISC
123
+ - COPYING-MIT
124
+ - COPYING-RUBY
125
+ - Gemfile
126
+ - Guardfile
127
+ - README.adoc
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - gemfiles/Rails-4.0.gemfile
132
+ - gemfiles/Rails-4.1.gemfile
133
+ - gemfiles/Rails-4.2.gemfile
134
+ - gemfiles/Rails-head.gemfile
135
+ - lib/template_tags.rb
136
+ - lib/template_tags/railtie.rb
137
+ - lib/template_tags/version.rb
138
+ - lib/template_tags/view_helper.rb
139
+ - template_tags.gemspec
140
+ homepage: https://github.com/skalee/template_tags
141
+ licenses:
142
+ - Ruby
143
+ - MIT
144
+ - ISC
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.4.5.1
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Simple view helper for Rails which makes embedding client-side templates
166
+ in views bit easier.
167
+ test_files: []
168
+ has_rdoc: