Skip to content

dev: replace sailfish with tera#341

Merged
da2ce7 merged 2 commits intotorrust:developfrom
da2ce7:20231014_use_tera
Oct 14, 2023
Merged

dev: replace sailfish with tera#341
da2ce7 merged 2 commits intotorrust:developfrom
da2ce7:20231014_use_tera

Conversation

@da2ce7
Copy link
Copy Markdown
Contributor

@da2ce7 da2ce7 commented Oct 14, 2023

No description provided.

@da2ce7 da2ce7 temporarily deployed to coverage October 14, 2023 20:12 — with GitHub Actions Inactive
@da2ce7 da2ce7 force-pushed the 20231014_use_tera branch from ac50802 to f610b92 Compare October 14, 2023 20:19
@da2ce7 da2ce7 temporarily deployed to coverage October 14, 2023 20:19 — with GitHub Actions Inactive
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 14, 2023

Codecov Report

Merging #341 (b0f2913) into develop (0491148) will increase coverage by 0.45%.
The diff coverage is 78.37%.

@@             Coverage Diff             @@
##           develop     #341      +/-   ##
===========================================
+ Coverage    43.92%   44.37%   +0.45%     
===========================================
  Files           77       77              
  Lines         4442     4473      +31     
===========================================
+ Hits          1951     1985      +34     
+ Misses        2491     2488       -3     
Files Coverage Δ
src/mailer.rs 41.25% <78.37%> (+34.23%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@da2ce7 da2ce7 temporarily deployed to coverage October 14, 2023 20:28 — with GitHub Actions Inactive
@da2ce7
Copy link
Copy Markdown
Contributor Author

da2ce7 commented Oct 14, 2023

ACK b0f2913

@da2ce7 da2ce7 merged commit aec16e6 into torrust:develop Oct 14, 2023
@josecelano
Copy link
Copy Markdown
Member

Why?

Both Sailfish and Tera are template engines for Rust. Let's look at their characteristics:

Sailfish:

  1. Performance: Sailfish claims to be extremely fast and is optimized for performance.
  2. Syntax: It has its own template syntax which can be more concise in some scenarios.
  3. Tooling: Offers some tooling like code completion and syntax highlighting for various editors.
  4. Flexibility: As with many template engines, you can extend and customize the behavior to suit your needs.

Tera:

  1. Jinja2-inspired: Tera's syntax and behavior are largely inspired by the Jinja2 template engine (commonly used with Python).
  2. Filters: It supports filters which can be used to modify variables inside templates.
  3. Inheritance and Macros: Tera supports template inheritance and macros, which can be powerful for creating reusable components and layouts.
  4. Safety: Tera ensures that the templates do not have access to the functions and methods of the variables passed to it, promoting safer templates.

Why might you choose Tera over Sailfish or vice versa?

  1. Familiarity with Jinja2: If you're familiar with Jinja2 (or Django templates), Tera might feel more intuitive.
  2. Project Requirements: If you need features like filters or macros, Tera could be more appealing.
  3. Performance: If raw speed is a crucial metric for your project, you might benchmark both engines with your use-case to see which one performs better.
  4. Syntax Preference: This can be subjective. Some developers might prefer the concise syntax of Sailfish, while others might prefer Tera's Jinja2-inspired syntax.

In the end, the choice between the two largely depends on your personal or project-specific needs and preferences. If you're unsure, it might be helpful to create a small prototype using both engines to see which one you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants