diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-07-27 21:59:34 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-07-27 21:59:34 -0400 |
commit | 955d28062d6926b5ba30b4e306715e3b0454bd1b (patch) | |
tree | 12420ea4c7332fbbb48e086c46efd95ba193c8a6 | |
parent | e3805c06a5ac24faaf791a2502c7dcdde843cc2a (diff) | |
download | guff-955d28062d6926b5ba30b4e306715e3b0454bd1b.tar.bz2 guff-955d28062d6926b5ba30b4e306715e3b0454bd1b.zip |
use theme templates for blog-list-item
-rw-r--r-- | data/themes/default/templates/blog-list-item.html | 8 | ||||
-rw-r--r-- | src/guff/views/blog/list.cr | 19 | ||||
-rw-r--r-- | src/guff/views/template-html.cr | 3 | ||||
-rw-r--r-- | src/views/blog/list-item.ecr | 4 |
4 files changed, 23 insertions, 11 deletions
diff --git a/data/themes/default/templates/blog-list-item.html b/data/themes/default/templates/blog-list-item.html new file mode 100644 index 0000000..f2c6c9f --- /dev/null +++ b/data/themes/default/templates/blog-list-item.html @@ -0,0 +1,8 @@ +<div class='guff-blog-list-item'> + <b>%{name|h}</b><br/> + <b> + by <span class='user'>%{user_name|h}</span> + on <span class='date'>%{posted_at_text|h}</span> + </b><br/><br/> + %{body} +</div> diff --git a/src/guff/views/blog/list.cr b/src/guff/views/blog/list.cr index a98131e..00bd587 100644 --- a/src/guff/views/blog/list.cr +++ b/src/guff/views/blog/list.cr @@ -19,15 +19,16 @@ class Guff::Views::Blog::ListView < Guff::Views::TemplateHTMLView theme_id: site["theme_id"].as(Int64).to_i32, theme_slug: site["theme_slug"].as(String), template_id: "blog-list.html", - data: { - "name" => TITLE, - "body" => String.build do |io| - # render items - results.rows.each do |row| - ListItemView.new(context, row).to_s(io) - end - end, - }, ) + + self.data = { + "name" => TITLE, + "body" => String.build do |io| + # render items + results.rows.each do |row| + theme_templates["blog-list-item.html"].run(io, row) + end + end, + } of String => String end end diff --git a/src/guff/views/template-html.cr b/src/guff/views/template-html.cr index 6ad5859..b7cd8e0 100644 --- a/src/guff/views/template-html.cr +++ b/src/guff/views/template-html.cr @@ -1,12 +1,13 @@ class Guff::Views::TemplateHTMLView < Guff::Views::HTMLView getter :theme_templates + property :data def initialize( context : Context, @theme_id : Int32, @theme_slug : String, @template_id : String, - @data : Hash(String, String), + @data : Hash(String, String) = {} of String => String, @extra_assets : Theme::Assets? = nil, ) super(context) diff --git a/src/views/blog/list-item.ecr b/src/views/blog/list-item.ecr index 23b868e..9a3bc72 100644 --- a/src/views/blog/list-item.ecr +++ b/src/views/blog/list-item.ecr @@ -1,4 +1,6 @@ -<div class='post'> +<% + # deprecated: replaced with theme templates +%><div class='post'> <b><%= h(@item["name"]) %></b><br/> <b> by <%= h(@item["user_name"]) %> |