The reason it was so hard to pass in a block outside of a template is because you're not supposed to do that :/
you're supposed to just use moonscript to build it
This commit is contained in:
parent
28405ca11b
commit
4bca13c559
19
index.html
19
index.html
@ -1,6 +1,19 @@
|
||||
{
|
||||
date: "Thu May 08 2025 19:41:30.000000000"
|
||||
}
|
||||
<p>just_render: $just_render_the_damn_list{limit = 2}</p>
|
||||
|
||||
$map{$do_unpack{}}
|
||||
|
||||
$(do_other())[[what $rank, ]]
|
||||
|
||||
<ul>$({"ho", "he"})[[<li>$it</li>]]</ul>
|
||||
|
||||
$({{"one", "hossssssss"}, {"two", "hesssssssssssssss"}})[[$1 and $2]]
|
||||
|
||||
$({{rank = "ok"}})[[what $rank, ]]
|
||||
|
||||
$do_cards[[this $rank, ]]
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
$map{{'one', 'Spades', 3}, {'two', 'Hearts', 4}}[[$1 and $2 or $3]]
|
||||
|
||||
|
65
site.moon
65
site.moon
@ -43,6 +43,7 @@ rootname = (str) ->
|
||||
result = string.gsub str, "%..+", ""
|
||||
result
|
||||
|
||||
reflect = (obj) -> [key for key, value in pairs obj]
|
||||
last = (list) -> list[#list]
|
||||
reverse = (list={}) -> [item for item in *list[#list, 1, -1]]
|
||||
|
||||
@ -191,6 +192,12 @@ four1 = (template) =>
|
||||
-- p list
|
||||
-- return [common.fill_ignoring_pre template, item for item in *list]
|
||||
|
||||
get_posts = (limit) =>
|
||||
pages = @site\query_pages { is_a: "post" }
|
||||
table.sort pages, (a, b) -> a.source > b.source
|
||||
limit_or_page_count = math.min limit or #pages, #pages
|
||||
[post for post in *pages[1, limit_or_page_count]]
|
||||
|
||||
sitegen.create =>
|
||||
@site_title = "WebDevCat.me"
|
||||
@app_name = "stasis"
|
||||
@ -200,6 +207,7 @@ sitegen.create =>
|
||||
@list2 = list2
|
||||
@list3 = list3
|
||||
|
||||
@some_name = "robertino farterino"
|
||||
@some_list = {
|
||||
{say: "this"}
|
||||
{say: "that"}
|
||||
@ -210,15 +218,60 @@ sitegen.create =>
|
||||
@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
|
||||
unpack for post in *get_posts @, arg.limit
|
||||
common.fill_ignoring_pre template, listing_info post
|
||||
|
||||
@map = (...) => cosmo.map ...
|
||||
|
||||
@do_cards = {{rank: "Ace", suit: "Spades"}, {rank: "Queen", suit: "Diamonds"}}
|
||||
|
||||
@do_other = (arg, _) =>
|
||||
{{rank: "Ace", suit: "Spades"}, {rank: "Queen", suit: "Diamonds"}}
|
||||
|
||||
@do_unpack = (arg, _) =>
|
||||
unpack {"three", "five", "seven"}
|
||||
|
||||
@just_render_the_damn_list = (arg={}, _) =>
|
||||
posts = [listing_info post for post in *get_posts @, arg.limit]
|
||||
|
||||
html.build ->
|
||||
return for post in *posts
|
||||
tag.section {
|
||||
tag.h3 { tag.a { post.title, href: post.url }}
|
||||
tag.time { post.publish_date }
|
||||
"—"
|
||||
post.blurb
|
||||
tag.a { "Read post →", href: post.url }
|
||||
}
|
||||
|
||||
-- [tag.section { "hoh" } for post in *posts]
|
||||
-- for key,value in pairs(o) do
|
||||
-- print("found member " .. key);
|
||||
-- end
|
||||
-- p @@__name
|
||||
-- p @.source
|
||||
-- p reflect @
|
||||
-- p reflect @renderer
|
||||
|
||||
-- unpack for post in *get_posts @, arg.limit
|
||||
-- common.fill_ignoring_pre template, listing_info post
|
||||
-- return for post in *get_posts @, arg.limit
|
||||
-- p reflect post
|
||||
-- p reflect post
|
||||
-- p post\get_tpl_scope!
|
||||
-- p post.meta
|
||||
-- common.fill_ignoring_pre template, listing_info post
|
||||
-- p reflect post
|
||||
-- p html_renderer
|
||||
-- p html_renderer.__base
|
||||
-- p html_renderer.cosmo_helpers
|
||||
-- html_renderer.render
|
||||
-- p post.renderer.helpers post
|
||||
-- p html_renderer.__base
|
||||
-- p reflect @@__base
|
||||
|
||||
-- html.build -> tag.h2 { "justrender call: $some_name (doesn't work)" }
|
||||
|
||||
add_all = (files) ->
|
||||
for path in *files
|
||||
add path,
|
||||
|
Loading…
x
Reference in New Issue
Block a user