Skip to main content

BladeEngine

Struct BladeEngine 

Source
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

Source

pub fn empty() -> Self

Membuat BladeEngine kosong (tanpa membaca views path, cocok untuk test/memory engine)

Source

pub fn new() -> Self

Source

pub fn with_plugin_runner(self, runner: Arc<dyn BladePluginRunner>) -> Self

Pasang plugin_runner kustom/global (misal dari PakemPluginManager)

Source

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

Source

pub fn reload_templates(&mut self, views_path: &str)

Source

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”)

Source

pub fn render_string(&self, content: &str, context: &BladeContext) -> String

Render string template secara langsung tanpa membaca file

Source

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)

Source

pub fn format_rupiah(input: &str) -> String

Helper Native: Format angka ke format mata uang Rupiah

Source

pub fn slug(input: &str) -> String

Helper Native: Mengubah teks menjadi slug URL (contoh: “Halo Dunia!” -> “halo-dunia”)

Source

pub fn production_shield_html() -> &'static str

HTML, CSS, dan JavaScript untuk proteksi template di browser (Anti-DevTools, Anti-Inspect, Anti-Copy)

Source

pub fn minify_html(input: &str) -> String

Helper minifikasi dokumen HTML (menghilangkan baris kosong, komentar, dan memadatkan whitespace menjadi 1 baris)

Trait Implementations§

Source§

impl Default for BladeEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.