easy_template 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/easy_template.rb +10 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e329d8b97804b7d7355033d9f7ee16ec9387aa6
4
+ data.tar.gz: 2450f2f375b1190801d9827ee917a0ec72c4f8e5
5
+ SHA512:
6
+ metadata.gz: 3211675cc558a2955a2742174fadd68c81a917a688d9a51a0627370d204ffdda4722b5061a41f9f52c871e051dab3769085db10ebf8e678dfaeacf34a856a6b8
7
+ data.tar.gz: 075a3a2eda6fb116c9de2c8df09e893e3973fa8274857c980b8840ca1d23a30ca390fb9e19ed134b02833fc500a53b977b59535f7df1d78b8cbd7fde23bb2b1d
@@ -0,0 +1,10 @@
1
+ module EasyTemplate
2
+ # Arguments:
3
+ # text: (String)
4
+ # the string containing your template
5
+ # variables: (Hash)
6
+ # the hash containing the values to substitute in place of the keys enclosed by { and }.
7
+ def self.process(text, variables)
8
+ text.gsub(/(\\\{)|((?<!\\)(?:\\\\)*#{variables.map{|v|"\\{#{v[0]}\\}"}.join('|')})/i){|s| s[0] == '\\' ? s[1] : variables[s[1..-2]]}
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easy_template
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jérémy Lecerf
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Easy template language in ruby, with only variable substitution.
14
+ email: redpist.com@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/easy_template.rb
20
+ homepage: https://github.com/redpist/easy-template
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.2.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Easy template language in ruby
44
+ test_files: []