-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
f2f331e
commit bceb2f0
Showing
10 changed files
with
79 additions
and
79 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
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
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
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
module Water | ||
macro embed(filename, io_name) | ||
{{ io_name.id }} << {{ run("./embedder.cr", filename) }} | ||
{{ io_name.id }} | ||
class Water | ||
macro embed(filename, io_name, layout_file = nil) | ||
{% if layout_file %} | ||
{{ io_name.id }} << {{ read_file(layout_file).gsub(/yield_content/, read_file(filename)).id }} | ||
{{ io_name.id }} | ||
{% else %} | ||
{{ io_name.id }} << {{ run("./embedder.cr", filename) }} | ||
{{ io_name.id }} | ||
{% end %} | ||
end | ||
end |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
puts "Water::Page.new do" | ||
puts "Water.new do" | ||
puts File.read(ARGV[0]) | ||
puts "end" |
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
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
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 |
---|---|---|
@@ -1,55 +1,45 @@ | ||
module Water | ||
class Water | ||
module OpenTag | ||
macro def_open_tag(tag) | ||
def {{tag.id}}(attributes = "") | ||
@lines << "<{{tag.id}}#{strip_attributes(attributes)}>" | ||
macro def_open_tag(tag, alias_name = nil) | ||
{% real_tag = alias_name || tag %} | ||
|
||
def {{tag.id}} | ||
@lines << "<{{real_tag.id}}>" | ||
@indents << @current_indent | ||
@current_indent += 1 | ||
yield | ||
@current_indent -= 1 | ||
@lines << "</{{tag.id}}>" | ||
@indents << @current_indent | ||
end | ||
|
||
def {{tag.id}}(attributes, content) | ||
@lines << "<{{tag.id}}#{strip_attributes(attributes)}>#{strip_content(content)}</{{tag.id}}>" | ||
@indents << @current_indent | ||
end | ||
|
||
def {{tag.id}}(content) | ||
@lines << "<{{tag.id}}>#{strip_content(content)}</{{tag.id}}>" | ||
@lines << "</{{real_tag.id}}>" | ||
@indents << @current_indent | ||
end | ||
end | ||
|
||
OPEN_TAGS = %w(a abbr address article aside b bdi body button code details dialog div dd dl dt em fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header html i iframe label li main mark menuitem meter nav ol option pre progress rp rt ruby s section small span strong summary table tbody td textarea th thead time title tr u ul video wbr) | ||
{% for tag in OPEN_TAGS %} | ||
def_open_tag {{tag}} | ||
{% end %} | ||
|
||
macro def_renamed_open_tag(tag, alias_name) | ||
def {{alias_name.id}}(attributes = "") | ||
@lines << "<{{tag.id}}#{strip_attributes(attributes)}>" | ||
def {{tag.id}}(attributes : String) | ||
@lines << "<{{real_tag.id}} #{attributes}>" | ||
@indents << @current_indent | ||
@current_indent += 1 | ||
yield | ||
@current_indent -= 1 | ||
@lines << "</{{tag.id}}>" | ||
@lines << "</{{real_tag.id}}>" | ||
@indents << @current_indent | ||
end | ||
|
||
def {{alias_name.id}}(attributes, content) | ||
@lines << "<{{tag.id}}#{strip_attributes(attributes)}>#{strip_content(content)}</{{tag.id}}>" | ||
def {{tag.id}}(attributes : String, content) | ||
@lines << "<{{real_tag.id}} #{attributes}>#{strip_content(content)}</{{real_tag.id}}>" | ||
@indents << @current_indent | ||
end | ||
|
||
def {{alias_name.id}}(content) | ||
@lines << "<{{tag.id}}>#{strip_content(content)}</{{tag.id}}>" | ||
def {{tag.id}}(content) | ||
@lines << "<{{real_tag.id}}>#{strip_content(content)}</{{real_tag.id}}>" | ||
@indents << @current_indent | ||
end | ||
end | ||
|
||
def_renamed_open_tag "p", "para" | ||
def_renamed_open_tag "select", "select_tag" | ||
OPEN_TAGS = %w(a abbr address article aside b bdi body button code details dialog div dd dl dt em fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header html i iframe label li main mark menuitem meter nav ol option pre progress rp rt ruby s section small span strong summary table tbody td textarea th thead time title tr u ul video wbr) | ||
{% for tag in OPEN_TAGS %} | ||
def_open_tag {{tag}} | ||
{% end %} | ||
|
||
def_open_tag "para", "p" | ||
def_open_tag "select_tag", "select" | ||
end | ||
end |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Water | ||
class Water | ||
VERSION = "0.2.0" | ||
end |