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 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 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().