-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
trenni (3.14.0) | ||
|
||
PLATFORMS | ||
ruby | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
trenni (~> 3.9) | ||
|
||
BUNDLED WITH | ||
2.5.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "trenni", "~> 3.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'trenni' | ||
require 'trenni/version' | ||
|
||
class Formatter | ||
def title_for(options) | ||
options[:title] | ||
end | ||
|
||
def value_for(options) | ||
options[:value] | ||
end | ||
|
||
def row(options = {}, &block) | ||
Trenni::Builder.fragment do |builder| | ||
builder.inline(:dt) { builder.text title_for(options) } | ||
|
||
if block_given? | ||
builder.inline(:dd) { builder.capture(self, &block) } | ||
else | ||
builder.inline(:dd) { builder.text value_for(options) } | ||
end | ||
end >> block | ||
end | ||
end | ||
|
||
puts "Trenni version: #{Trenni::VERSION}" | ||
|
||
template = Trenni::Template.load_file('test.trenni') | ||
puts template.to_string(binding) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?r | ||
f = Formatter.new | ||
?> | ||
|
||
# Test Interpolation | ||
#{f.row :title => 'Test title', :value => "Test value"} | ||
|
||
# Test Tag | ||
<?r f.row title: 'Title Test' do ?> | ||
<a href="test-link">Test Link</a> | ||
<?r end ?> | ||
|
||
# Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require_relative 'lib/xrb' | ||
|
||
class Formatter | ||
def title_for(options) | ||
options[:title] | ||
end | ||
|
||
def value_for(options) | ||
options[:value] | ||
end | ||
|
||
def row(options = {}, &block) | ||
XRB::Builder.fragment do |builder| | ||
builder.inline(:dt) { builder.text title_for(options) } | ||
|
||
if block_given? | ||
binding.irb | ||
builder.inline(:dd) { builder.capture(self, &block) } | ||
else | ||
builder.inline(:dd) { builder.text value_for(options) } | ||
end | ||
end | ||
end | ||
end | ||
|
||
template = XRB::Template.load_file('test.xrb') | ||
|
||
binding.irb | ||
|
||
puts template.to_string(binding) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?r | ||
f = Formatter.new | ||
?> | ||
|
||
# Test Interpolation | ||
#{f.row :title => 'Test title', :value => "Test value"} | ||
|
||
# Test Tag | ||
<?r f.row title: 'Title Test' do ?> | ||
<a href="test-link">Test Link</a> | ||
<?r end ?> | ||
|
||
# Done |