pub struct Context { /* private fields */ }Expand description
BladeContext — Menyimpan data dan variabel untuk dirender ke dalam template Blade. Mendukung nested properties (dot-notation), array indexing, dan serialisasi data dinamis.
Implementations§
Source§impl BladeContext
impl BladeContext
pub fn new() -> BladeContext
Sourcepub fn push_to_stack(&self, name: &str, content: String)
pub fn push_to_stack(&self, name: &str, content: String)
Push konten ke stack tertentu (Laravel: @push(‘name’))
Sourcepub fn prepend_to_stack(&self, name: &str, content: String)
pub fn prepend_to_stack(&self, name: &str, content: String)
Prepend konten ke stack tertentu (Laravel: @prepend(‘name’))
Sourcepub fn get_stack(&self, name: &str) -> String
pub fn get_stack(&self, name: &str) -> String
Ambil akumulasi konten stack tertentu (Laravel: @stack(‘name’))
Sourcepub fn check_and_mark_once(&self, id: &str) -> bool
pub fn check_and_mark_once(&self, id: &str) -> bool
Cek dan tandai eksekusi blok @once
Sourcepub fn insert<T>(&mut self, key: &str, value: T)where
T: Serialize,
pub fn insert<T>(&mut self, key: &str, value: T)where
T: Serialize,
Masukkan data serializable ke dalam context.
Sourcepub fn insert_val(&mut self, key: &str, value: Value)
pub fn insert_val(&mut self, key: &str, value: Value)
Masukkan Value serde_json langsung.
Sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Ambil nilai variabel. Mendukung dot-notation (misal: “user.profile.name” atau “items.0.title”).
Sourcepub fn check_user_can(&self, permission: &str) -> bool
pub fn check_user_can(&self, permission: &str) -> bool
Cek apakah ada pesan error validasi untuk kolom tertentu. Cek apakah user memiliki izin tertentu (RBAC support di Blade view)
Sourcepub fn check_user_has_role(&self, role: &str) -> bool
pub fn check_user_has_role(&self, role: &str) -> bool
Cek apakah user memiliki peran tertentu (RBAC support di Blade view)
pub fn has_error(&self, field: &str) -> bool
Sourcepub fn get_error(&self, field: &str) -> Option<String>
pub fn get_error(&self, field: &str) -> Option<String>
Ambil pesan error validasi untuk kolom tertentu jika ada.
Sourcepub fn is_truthy(val: Option<&Value>) -> bool
pub fn is_truthy(val: Option<&Value>) -> bool
Cek apakah suatu nilai bertipe truthy menurut aturan Blade/Laravel.
Sourcepub fn split_concat_tokens(expr: &str) -> Option<Vec<String>>
pub fn split_concat_tokens(expr: &str) -> Option<Vec<String>>
Tokenizer untuk operator titik (konkatenasi string ala PHP/Laravel).
Contoh: 'storage/images/meals/' . $meal.image -> ["'storage/images/meals/'", "$meal.image"]
Sourcepub fn find_argument_split(s: &str) -> Option<usize>
pub fn find_argument_split(s: &str) -> Option<usize>
Helper mencari posisi pemisah koma terluar pada pemanggilan fungsi berargumen banyak.
Sourcepub fn find_token_outside_parens(s: &str, token: &str) -> Option<usize>
pub fn find_token_outside_parens(s: &str, token: &str) -> Option<usize>
Helper mencari token terluar (di luar tanda kurung/kutip).
Sourcepub fn split_arguments(s: &str) -> Vec<String>
pub fn split_arguments(s: &str) -> Vec<String>
Helper memecah argumen berdasar koma terluar (misal: “a, [1, 2], ‘x, y’”) -> [“a”, “[1, 2]”, “‘x, y’”]
Sourcepub fn parse_blade_array(
raw: &str,
ctx: &BladeContext,
) -> HashMap<String, Value>
pub fn parse_blade_array( raw: &str, ctx: &BladeContext, ) -> HashMap<String, Value>
Helper parsing array/hashmap sintaks Blade PHP: Contoh: “[‘title’ => $title, ‘status’ => ‘active’, ‘count’ => 5]” atau “compact(‘item’, ‘title’)”
Sourcepub fn format_thousands(val_str: &str, sep: char) -> String
pub fn format_thousands(val_str: &str, sep: char) -> String
Helper format angka ribuan (e.g. 15000 -> “15.000” atau “15,000”).
Sourcepub fn parse_date_parts(raw: &str) -> Option<(u32, u32, i32)>
pub fn parse_date_parts(raw: &str) -> Option<(u32, u32, i32)>
Helper parsing komponen tanggal (day, month, year) dari string format database.
Sourcepub fn format_php_date(format_str: &str, raw_date: &str) -> String
pub fn format_php_date(format_str: &str, raw_date: &str) -> String
Helper format tanggal PHP (e.g. ‘d F Y’, ‘d M’, ‘d M Y’).
Sourcepub fn format_tanggal_indo(raw_date: &str) -> String
pub fn format_tanggal_indo(raw_date: &str) -> String
Helper format tanggal Indonesia (e.g. 20 Mei 2024).
Sourcepub fn format_tanggal_eng(raw_date: &str) -> String
pub fn format_tanggal_eng(raw_date: &str) -> String
Helper format tanggal Inggris (e.g. 20 May 2024).
Sourcepub fn eval_val(&self, expr: &str) -> String
pub fn eval_val(&self, expr: &str) -> String
Evaluasi nilai ekspresi variabel/literal menjadi String.
Mendukung null coalescing: $name ?? 'Default'
Sourcepub fn eval_truthy(&self, expr: &str) -> bool
pub fn eval_truthy(&self, expr: &str) -> bool
Evaluasi kondisi boolean (truthy) untuk direktif @if, @unless, @checked, dll.
Trait Implementations§
Source§impl Clone for BladeContext
impl Clone for BladeContext
Source§fn clone(&self) -> BladeContext
fn clone(&self) -> BladeContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BladeContext
impl Debug for BladeContext
Source§impl Default for BladeContext
impl Default for BladeContext
Source§fn default() -> BladeContext
fn default() -> BladeContext
Auto Trait Implementations§
impl Forget for BladeContext
impl Freeze for BladeContext
impl Move for BladeContext
impl RefUnwindSafe for BladeContext
impl Send for BladeContext
impl Sync for BladeContext
impl Unpin for BladeContext
impl UnsafeUnpin for BladeContext
impl UnwindSafe for BladeContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().