Questions tagged [tera]

Tera is an open-source template engine written in rust.

Tera is a template engine written in the programming language.

References

24 questions
8
votes
1 answer

How to filter Taxonomies using Rust-based Zola / Tera?

I have recently discovered Zola and Tera (Rust frameworks for statically-generated websites) and found them amazing. I'm trying to filter specific category pages to display in a section on the same page. To illustrate, I wrote some code like…
ikevin8me
  • 4,253
  • 5
  • 44
  • 84
5
votes
1 answer

How can I iterate over the terms in a taxonomy outside the list.html using Zola?

I've found out you can use {% set posts = get_taxonomy(kind="posts") %} to retrieve a taxonomy but I'm clueless how to iterate over the terms of the taxonomy in for example single.html of this taxonomy. I tried things like the following, but I…
6754534367
  • 5,123
  • 4
  • 17
  • 24
3
votes
1 answer

Why can't my rust code load a tera template?

I have a rust application (https://github.com/Riduidel/rrss2imap) which, when run on my raspberry, fails with the following error message pi@raspberrypi-server:~/rrss2imap $ ./rrss2imap-armv7-unknown-linux-gnueabihf-debug run [2019-09-02…
Riduidel
  • 22,052
  • 14
  • 85
  • 185
3
votes
1 answer

How can I iterate over the posts of a section using Zola?

I tried the following, which I found in the Zola documentation but it didn't render anything. The Tera docs weren't rewarding either. {% for post in section.pages %}

{{ post.title }}

{% endfor %}
6754534367
  • 5,123
  • 4
  • 17
  • 24
2
votes
1 answer

How to convert tera::Error to actix_web::Error?

I'm studying rust/actix/tera and cannot figure out how to implement ResponseError trait on the tera::Error, or alternatively how to convert tera::Error to actix_web::Error. With the following code snippet: match TEMPLATES.render("index.html", &ctx)…
NarūnasK
  • 4,564
  • 8
  • 50
  • 76
2
votes
1 answer

How to display custom Tera errors in Actix?

I'm studying rust/actix/tera and cannot figure out how may I return a custom tera error string in the actix output. Here's my code: use actix_web::{App, get, error, Error, HttpResponse, HttpServer}; use tera::{Tera, Context}; use…
NarūnasK
  • 4,564
  • 8
  • 50
  • 76
2
votes
0 answers

Rust: passing functions/filters to Tera templating

I have a Tera (Jinja2 alike) template which requires 2 functions to be imported. Raises expected function that takes 2 arguments. How do I approach this? One of the functions: #[derive(Serialize)] #[derive(Debug)] enum Color { White, Blue, …
ArekBulski
  • 4,520
  • 4
  • 39
  • 61
2
votes
1 answer

Which Static Site Generator can generate pages by just iterating through an assets directory of images (without any content format (e.g. MD) files)?

I'm thinking of publishing a photography blog. Normally, a Static Site Generator generates the site pages based on .MD files and the linked images placed in an assets directory. I'm looking for a Static Site Generator which can generated all the…
ikevin8me
  • 4,253
  • 5
  • 44
  • 84
1
vote
0 answers

Ship tera templates in a crate without embedding them into the binary

I am using tera and want to make a CLI that acts as a new project generator (think rails scaffold). There will be quite a few templates and I would like to ship them in my crate as an asset file and read from disk instead of using include_str! and…
Schneems
  • 14,918
  • 9
  • 57
  • 84
1
vote
1 answer

Why does Tera say TemplateNotFound when rendering a template?

I am experimenting with building a web app in Rust using Tera and there is a panic every time on the render() call below. Example of the chunk of code: async fn login(tera: web::Data) -> impl Responder { let mut data = Context::new(); …
Matt H
  • 19
  • 2
1
vote
1 answer

How to use rocket::response::Flash in a tera template

I am currently re-writing a web application built in python/flask that uses flashes as so: {% with flashes = get_flashed_messages() %} {% if flashes %}
    {% for message in flashes %}
  • {{ message }} …
banksdev
  • 198
  • 1
  • 1
  • 8
1
vote
1 answer

How to create array using Tera in Rust?

I am stuck in a simple problem but not able to figure it. I am not sure if this is the right place to ask the question on a package in Rust. Most of the time, in the template, we will want to transform our data. For example, I wanted to concat n…
Selva
  • 951
  • 7
  • 23
0
votes
1 answer

actix_web + tera tamplates give me [actix_web::data] Failed to extract `Data` for `index` handler wrap the data with `Data::new()`

I tried to make actix-web and Tera work together, from examples I found online. This is my code: use actix_web::{get, web, Result, App, HttpServer, HttpRequest, Responder, HttpResponse}; use serde::{Deserialize,Serialize}; use tera::{Tera,…
user63898
  • 29,839
  • 85
  • 272
  • 514
0
votes
0 answers

Zola static site generator and localization (l10n)

The problem I'm new to Zola and its templating engine Tera, and I'm struggling with making my own Zola theme easily localizable, even providing some out-of-the-box translations for e.g. English and German. Zolas's fluent integration is not there yet…
tweitzel
  • 333
  • 3
  • 10
0
votes
1 answer

tera: Display line number and type of the failure for rendering errors

I have the following code in Rust using tera template language: let mut context = Context::new(); context.insert("adminform", &admin_form); let html = match tera.render("change_form.html", &context) { Ok(html) => html, …
gruszczy
  • 40,948
  • 31
  • 128
  • 181
1
2