Comments (7)
Unfortunately, I think the structure you’re looking for isn’t a feature of Temple. I did a bit of searching - I think jinja refers to that usage as ‘template inheritance’. I asked after that feature myself and I think it’s out of scope for Temple.
In practice , I just include a header and a footer separately , rather than a single skeleton with the header and footer content, and a hole called ‘content’. But I could imagine for more complex layouts, that approach might not scale.
Under the hood temple is just string macros… I wouldn’t be surprised if you could magic a way up to do codegen on individual temple templates!
from log.
makes sense! do you think the approach I'm trying in my previous comment may be an option? (assuming I figure out how to actually make it work sweat_smile)
It might need more metaprogramming. I think at least some of this is happening in runtime when it needs to happen at macro expansion time.
That said, I'm mildly nerdsniped and might try it out this evening!
from log.
ah maybe this will help?
https://git.sr.ht/~bakpakin/temple/tree/master/item/test/templates/hop.temple
from log.
This almost works but can't get the :_slot
to actually render when building
# base.temple
<html>
{{ (get-in args [:_slot]) }}
</html>
# log.temple
<p>Some log</p>
# wrapped.temple
{$
(import ./base :as base)
(import ./log :as log) $}
{% (base/render-dict (merge args {:_slot (log/render-dict args)})) %}
Wondering what I'm missing 🤔
from log.
Unfortunately, I think the structure you’re looking for isn’t a feature of Temple. I did a bit of searching - I think jinja refers to that usage as ‘template inheritance’. I asked after that feature myself and I think it’s out of scope for Temple.
In practice , I just include a header and a footer separately , rather than a single skeleton with the header and footer content, and a hole called ‘content’. But I could imagine for more complex layouts, that approach might not scale.
makes sense! do you think the approach I'm trying in my previous comment may be an option? (assuming I figure out how to actually make it work 😅)
Under the hood temple is just string macros… I wouldn’t be surprised if you could magic a way up to do codegen on individual temple templates!
probably a way of doing it but my lack of knowledge fails me for now 😅
from log.
@subsetpark was poking around Mendoza and looks like it supports template inheritance using :template
! (see section about {{ node }}
)
https://bakpakin.github.io/mendoza/templating.html
Haven't taken a look at the implementation but maybe something to look at if you feel curious again 😄
from log.
Todo: look into whether pepe's example is what I'm looking for:
https://git.sr.ht/~pepe/neil/tree/master/item/templates/app.temple
https://git.sr.ht/~pepe/neil/tree/master/item/neil/watch/init.janet
https://janet-lang.org/api/spork/index.html#spork/misc/capout
from log.
Related Issues (3)
- RSS support HOT 2
- tooling
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log.