From 3c293d2320d21284f8688adb4694d5e2bf4ecfae Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Thu, 22 May 2025 22:48:19 -0700 Subject: [PATCH] WIP --- index.html | 8 ++++++++ site.moon | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 2a8ee81..49a04cf 100644 --- a/index.html +++ b/index.html @@ -2,10 +2,18 @@ date: "Thu May 08 2025 19:41:30.000000000" } +$map{{'one', 'Spades', 3}, {'two', 'Hearts', 4}}[[$1 and $2 or $3]] + +
+ $one{some_var = "paris"} $two{limit = "here"}[[the limit is $limit]] +$three{$some_list}[[say $say]] + +$map{$four{limit = 2}} +
$list3{ limit = 2 }[[ diff --git a/site.moon b/site.moon index 69cfe0c..bd08593 100644 --- a/site.moon +++ b/site.moon @@ -162,14 +162,9 @@ list2 = (args={}) => url = rootname page\url_for! vals = { title: title, publish_date: pub_date, blurb: blurb, url: url } - html = page.site\get_renderer "sitegen.renderers.html" - page\merge_meta vals - page.tpl_scope = page.meta - page.template_stack = common.Stack! - html\render page, assert args[1] or template, "missing html string" - return if args[1] then table.concat result else result + one = (template) => (arg, _has_block) => common.fill_ignoring_pre template, arg @@ -179,6 +174,23 @@ two = (arg, has_block) => cosmo.yield arg nil -- VERY IMPORTANT! +three = (arg, has_block) => + common.throw_error "expecting a block" if not has_block + { list } = arg + cosmo.yield item for item in *list + nil -- VERY IMPORTANT! + +four1 = (template) => + (arg, _has_block) => + { list } = arg + return [common.fill_ignoring_pre template, item for item in *list] + +-- four = (arg) => +-- p arg + -- { list } = arg + -- p list + -- return [common.fill_ignoring_pre template, item for item in *list] + sitegen.create => @site_title = "WebDevCat.me" @app_name = "stasis" @@ -188,8 +200,24 @@ sitegen.create => @list2 = list2 @list3 = list3 + @some_list = { + {say: "this"} + {say: "that"} + {say: "the other"} + } + @one = one @, [[inline template $some_var]] @two = two + @three = three + @four = (arg, _) => + pages = @site\query_pages { is_a: "post" } + table.sort pages, (a, b) -> a.source > b.source + limit_or_page_count = math.min arg.limit or #pages, #pages + + unpack for page in *pages[1, limit_or_page_count] + common.fill_ignoring_pre template, listing_info page + + @map = (...) => cosmo.map ... add_all = (files) -> for path in *files