pub struct BladeEngine {
pub templates: HashMap<String, String>,
pub plugin_runner: Arc<dyn BladePluginRunner>,
pub wasm_filters: HashMap<String, (String, String)>,
}Expand description
BladeEngine — Pure Native Laravel Blade Templating Engine for Rust. Sangat cepat, tanpa alokasi berat, mendukung layout inheritance, loop variables, conditional directives, integrasi Indonesian Script, serta Filter & Ekstensi WASM Sandbox.
Fields§
§templates: HashMap<String, String>§plugin_runner: Arc<dyn BladePluginRunner>§wasm_filters: HashMap<String, (String, String)>Implementations§
Source§impl BladeEngine
impl BladeEngine
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Membuat BladeEngine kosong (tanpa membaca views path, cocok untuk test/memory engine)
pub fn new() -> Self
Sourcepub fn with_plugin_runner(self, runner: Arc<dyn BladePluginRunner>) -> Self
pub fn with_plugin_runner(self, runner: Arc<dyn BladePluginRunner>) -> Self
Pasang plugin_runner kustom/global (misal dari PakemPluginManager)
Sourcepub fn register_wasm_filter(
&mut self,
alias: &str,
plugin_name: &str,
func_name: &str,
)
pub fn register_wasm_filter( &mut self, alias: &str, plugin_name: &str, func_name: &str, )
Daftarkan alias filter Blade kustom yang mengarah ke plugin WASM tertentu
pub fn reload_templates(&mut self, views_path: &str)
Sourcepub fn render(&self, template_name: &str, context: &BladeContext) -> String
pub fn render(&self, template_name: &str, context: &BladeContext) -> String
Render template menggunakan nama file atau format dot-notation (misal: “auth.login” atau “layouts/app.blade.rs”)
Sourcepub fn render_string(&self, content: &str, context: &BladeContext) -> String
pub fn render_string(&self, content: &str, context: &BladeContext) -> String
Render string template secara langsung tanpa membaca file
Sourcepub fn eval_expr_with_filters(
&self,
expr: &str,
context: &BladeContext,
) -> String
pub fn eval_expr_with_filters( &self, expr: &str, context: &BladeContext, ) -> String
Evaluasi ekspresi variabel atau literal yang mungkin memiliki filter berantai:
Contoh: $nominal | rupiah
Contoh: $title | slug | uppercase
Contoh: $content | limit: 100
Contoh: $comment | sensor_kata (WASM Sandbox)
Sourcepub fn format_rupiah(input: &str) -> String
pub fn format_rupiah(input: &str) -> String
Helper Native: Format angka ke format mata uang Rupiah
Sourcepub fn slug(input: &str) -> String
pub fn slug(input: &str) -> String
Helper Native: Mengubah teks menjadi slug URL (contoh: “Halo Dunia!” -> “halo-dunia”)
Sourcepub fn production_shield_html() -> &'static str
pub fn production_shield_html() -> &'static str
HTML, CSS, dan JavaScript untuk proteksi template di browser (Anti-DevTools, Anti-Inspect, Anti-Copy)
Sourcepub fn minify_html(input: &str) -> String
pub fn minify_html(input: &str) -> String
Helper minifikasi dokumen HTML (menghilangkan baris kosong, komentar, dan memadatkan whitespace menjadi 1 baris)