Skip to main content

Crate forge_codegen

Crate forge_codegen 

Source
Expand description

Forge → Askama preprocessor. Used from build.rs to compile .forge.html files into Askama-compatible .html templates.

Supports:

  • @if / @elseif / @else / @endif{% if %} / {% elif %} / {% else %} / {% endif %}
  • @foreach / @endforeach{% for %} / {% endfor %} (with loop.index, loop.first, etc.)
  • @extends('layout'){% extends "layout.html" %}
  • @section('name') / @endsection{% block name %} / {% endblock %}
  • @yield('name'){% block name %}{% endblock %}
  • @parent{{ super() }}
  • @include('partial'){% include "partial.html" %}
  • @push('stack') / @endpush → call into forge::stack::push
  • @stack('stack') → placeholder for post-render swap
  • @vite([...]) → call into forge::vite::render
  • @auth / @guest / @can — sugar over @if
  • {{ x }}{{ x }} (Askama auto-escapes)
  • {!! x !!}{{ x|safe }}
  • <x-component prop="...">body</x-component>{% call ... %}body{% endcall %}

Re-exports§

pub use compiler::compile_dir;
pub use compiler::compile_file;
pub use compiler::compile_source;
pub use compiler::compile_source_runtime;
pub use compiler::emit_embedded_registry;
pub use lower::LowerTarget;

Modules§

compiler
Compile Forge templates to Askama (compile-time, build.rs path) or to a MiniJinja-compatible runtime form used by Spark.
lower
Lower a Forge token stream into Askama template syntax (the default) or into a MiniJinja-compatible runtime form (for Spark component bodies and other dynamic templates).
parser
Parser for Forge .forge.html files. Produces a flat token stream that the lowering pass converts to Askama syntax.