aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-27 21:59:34 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-27 21:59:34 -0400
commit955d28062d6926b5ba30b4e306715e3b0454bd1b (patch)
tree12420ea4c7332fbbb48e086c46efd95ba193c8a6 /src
parente3805c06a5ac24faaf791a2502c7dcdde843cc2a (diff)
downloadguff-955d28062d6926b5ba30b4e306715e3b0454bd1b.tar.bz2
guff-955d28062d6926b5ba30b4e306715e3b0454bd1b.zip
use theme templates for blog-list-item
Diffstat (limited to 'src')
-rw-r--r--src/guff/views/blog/list.cr19
-rw-r--r--src/guff/views/template-html.cr3
-rw-r--r--src/views/blog/list-item.ecr4
3 files changed, 15 insertions, 11 deletions
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"]) %>