Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templating #1

Open
peppidesu opened this issue Nov 20, 2024 · 1 comment
Open

Templating #1

peppidesu opened this issue Nov 20, 2024 · 1 comment

Comments

@peppidesu
Copy link

As much as i like the macro idea, it isn't nearly as versatile as proper templating.

Instead of reinventing the wheel here, we should instead use something like Tera / Handlebars to do this for us.

@Bright-Shard
Copy link
Owner

Bright-Shard commented Nov 20, 2024

I agree that webby needs templating, but I don't want to just take existing systems at face value. I'd rather design something more carefully.

Couple of things:

  • I don't want to use tera, it pulls in a ridiculous amount of dependencies and part of the design of webby is that it's fast to compile (see list a the bottom of this comment).
  • Templates should integrate with webby.toml. Something like template = "path/to/my/template.html".
  • I'd like the syntax to feel more HTML-native. I actually don't like flask-style {% variable %}, it's annoying to type and I've had it break some formatters. I'm wondering if we could use something like <!TEMPLATE.variable>.

And while we're at it, I feel like macros could use a bit of a redesign. Since one of my goals is to allow custom macros in Lua, I'd like Lua to be able to integrate easier into webby.

dep list with tera added
webby on  main [!] is 📦 v0.1.0 via 🦀 v1.84.0-nightly took 2s 
❯ cargo tree
  Downloaded unicode-ident v1.0.14
  Downloaded itoa v1.0.13
  Downloaded serde_json v1.0.133
  Downloaded 3 crates (209.5 KB) in 0.76s
webby v0.1.0 (/home/bs/Dev/web/webby)
├── base64 v0.22.1
├── boml v0.3.1
└── tera v1.20.0
    ├── chrono v0.4.38
    │   ├── iana-time-zone v0.1.61
    │   └── num-traits v0.2.19
    │       [build-dependencies]
    │       └── autocfg v1.4.0
    ├── chrono-tz v0.9.0
    │   ├── chrono v0.4.38 (*)
    │   └── phf v0.11.2
    │       └── phf_shared v0.11.2
    │           └── siphasher v0.3.11
    │   [build-dependencies]
    │   └── chrono-tz-build v0.3.0
    │       ├── parse-zoneinfo v0.3.1
    │       │   └── regex v1.11.1
    │       │       ├── regex-automata v0.4.9
    │       │       │   └── regex-syntax v0.8.5
    │       │       └── regex-syntax v0.8.5
    │       ├── phf v0.11.2 (*)
    │       └── phf_codegen v0.11.2
    │           ├── phf_generator v0.11.2
    │           │   ├── phf_shared v0.11.2 (*)
    │           │   └── rand v0.8.5
    │           │       └── rand_core v0.6.4
    │           └── phf_shared v0.11.2 (*)
    ├── globwalk v0.9.1
    │   ├── bitflags v2.6.0
    │   ├── ignore v0.4.23
    │   │   ├── crossbeam-deque v0.8.5
    │   │   │   ├── crossbeam-epoch v0.9.18
    │   │   │   │   └── crossbeam-utils v0.8.20
    │   │   │   └── crossbeam-utils v0.8.20
    │   │   ├── globset v0.4.15
    │   │   │   ├── aho-corasick v1.1.3
    │   │   │   │   └── memchr v2.7.4
    │   │   │   ├── bstr v1.11.0
    │   │   │   │   └── memchr v2.7.4
    │   │   │   ├── log v0.4.22
    │   │   │   ├── regex-automata v0.4.9
    │   │   │   │   ├── aho-corasick v1.1.3 (*)
    │   │   │   │   ├── memchr v2.7.4
    │   │   │   │   └── regex-syntax v0.8.5
    │   │   │   └── regex-syntax v0.8.5
    │   │   ├── log v0.4.22
    │   │   ├── memchr v2.7.4
    │   │   ├── regex-automata v0.4.9 (*)
    │   │   ├── same-file v1.0.6
    │   │   └── walkdir v2.5.0
    │   │       └── same-file v1.0.6
    │   └── walkdir v2.5.0 (*)
    ├── humansize v2.1.3
    │   └── libm v0.2.11
    ├── lazy_static v1.5.0
    ├── percent-encoding v2.3.1
    ├── pest v2.7.14
    │   ├── memchr v2.7.4
    │   ├── thiserror v1.0.69
    │   │   └── thiserror-impl v1.0.69 (proc-macro)
    │   │       ├── proc-macro2 v1.0.89
    │   │       │   └── unicode-ident v1.0.14
    │   │       ├── quote v1.0.37
    │   │       │   └── proc-macro2 v1.0.89 (*)
    │   │       └── syn v2.0.87
    │   │           ├── proc-macro2 v1.0.89 (*)
    │   │           ├── quote v1.0.37 (*)
    │   │           └── unicode-ident v1.0.14
    │   └── ucd-trie v0.1.7
    ├── pest_derive v2.7.14 (proc-macro)
    │   ├── pest v2.7.14 (*)
    │   └── pest_generator v2.7.14
    │       ├── pest v2.7.14 (*)
    │       ├── pest_meta v2.7.14
    │       │   ├── once_cell v1.20.2
    │       │   └── pest v2.7.14 (*)
    │       │   [build-dependencies]
    │       │   └── sha2 v0.10.8
    │       │       ├── cfg-if v1.0.0
    │       │       ├── cpufeatures v0.2.15
    │       │       └── digest v0.10.7
    │       │           ├── block-buffer v0.10.4
    │       │           │   └── generic-array v0.14.7
    │       │           │       └── typenum v1.17.0
    │       │           │       [build-dependencies]
    │       │           │       └── version_check v0.9.5
    │       │           └── crypto-common v0.1.6
    │       │               ├── generic-array v0.14.7 (*)
    │       │               └── typenum v1.17.0
    │       ├── proc-macro2 v1.0.89 (*)
    │       ├── quote v1.0.37 (*)
    │       └── syn v2.0.87 (*)
    ├── rand v0.8.5
    │   ├── libc v0.2.164
    │   ├── rand_chacha v0.3.1
    │   │   ├── ppv-lite86 v0.2.20
    │   │   │   └── zerocopy v0.7.35
    │   │   │       ├── byteorder v1.5.0
    │   │   │       └── zerocopy-derive v0.7.35 (proc-macro)
    │   │   │           ├── proc-macro2 v1.0.89 (*)
    │   │   │           ├── quote v1.0.37 (*)
    │   │   │           └── syn v2.0.87 (*)
    │   │   └── rand_core v0.6.4
    │   │       └── getrandom v0.2.15
    │   │           ├── cfg-if v1.0.0
    │   │           └── libc v0.2.164
    │   └── rand_core v0.6.4 (*)
    ├── regex v1.11.1
    │   ├── aho-corasick v1.1.3 (*)
    │   ├── memchr v2.7.4
    │   ├── regex-automata v0.4.9 (*)
    │   └── regex-syntax v0.8.5
    ├── serde v1.0.215
    ├── serde_json v1.0.133
    │   ├── itoa v1.0.13
    │   ├── memchr v2.7.4
    │   ├── ryu v1.0.18
    │   └── serde v1.0.215
    ├── slug v0.1.6
    │   └── deunicode v1.6.0
    └── unic-segment v0.9.0
        └── unic-ucd-segment v0.9.0
            ├── unic-char-property v0.9.0
            │   └── unic-char-range v0.9.0
            ├── unic-char-range v0.9.0
            └── unic-ucd-version v0.9.0
                └── unic-common v0.9.0

Also, wikipedia has this page that could be interesting: https://en.wikipedia.org/wiki/Comparison_of_web_template_engines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants