Coder Social home page Coder Social logo

Comments (7)

subsetpark avatar subsetpark commented on July 22, 2024 1

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.

subsetpark avatar subsetpark commented on July 22, 2024 1

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.

achou11 avatar achou11 commented on July 22, 2024

ah maybe this will help?

https://git.sr.ht/~bakpakin/temple/tree/master/item/test/templates/hop.temple

from log.

achou11 avatar achou11 commented on July 22, 2024

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.

achou11 avatar achou11 commented on July 22, 2024

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.

achou11 avatar achou11 commented on July 22, 2024

@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.

achou11 avatar achou11 commented on July 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.