WIP
This commit is contained in:
parent
fd6e3411ff
commit
f69a01f0bf
@ -2,7 +2,9 @@
|
||||
date: "Thu May 08 2025 19:41:30.000000000"
|
||||
}
|
||||
|
||||
$test{ limit = "is this?" }[[what $limit]][[second $limit]]
|
||||
$list3{ limit = 2 }[[<section><h3>$title</h3></section>]]
|
||||
<hr />
|
||||
$list3{ limit = 2 }
|
||||
|
||||
$render{"templates/wares"}
|
||||
|
||||
|
22
site.moon
22
site.moon
@ -112,7 +112,7 @@ html_renderer.cosmo_helpers.titleize = (slug) => titleize_slug slug
|
||||
files_from = (path=".") ->
|
||||
[Path.join path, file for file in *reverse get_files path]
|
||||
|
||||
test = (args, has_block) =>
|
||||
test = (args={}, has_block) =>
|
||||
if has_block
|
||||
cosmo.yield(name: "yupyup")
|
||||
nil
|
||||
@ -126,6 +126,25 @@ test = (args, has_block) =>
|
||||
-- page.template_stack = common.Stack!
|
||||
-- html\render page, assert args[1] or template, "missing html string"
|
||||
|
||||
list3 = (args={}, has_block) =>
|
||||
pages = @site\query_pages { is_a: "post" }
|
||||
table.sort pages, (a, b) -> a.source > b.source
|
||||
limit_or_page_count = math.min args.limit or #pages, #pages
|
||||
|
||||
result = for page in *pages[1, limit_or_page_count]
|
||||
{ :title, :id, publish_date: pub_date, :blurb } = page.meta
|
||||
title = title or titleize_slug id
|
||||
url = rootname page\url_for!
|
||||
vals = { title: title, publish_date: pub_date, blurb: blurb, url: url }
|
||||
|
||||
if has_block
|
||||
cosmo.yield vals
|
||||
nil
|
||||
else
|
||||
common.fill_ignoring_pre template, vals
|
||||
|
||||
unless has_block then return table.concat result
|
||||
|
||||
-- use in templates
|
||||
-- $list2{[[<p>$title</p>]], limit = 2}
|
||||
-- $each{$list2({limit = 3}), "item"}[[$item]]
|
||||
@ -155,6 +174,7 @@ sitegen.create =>
|
||||
@list_posts = list_posts @, template
|
||||
@test = test
|
||||
@list2 = list2
|
||||
@list3 = list3
|
||||
|
||||
add_all = (files) ->
|
||||
for path in *files
|
||||
|
Loading…
x
Reference in New Issue
Block a user