NexaDom menyediakan sintaks kondisional yang powerful untuk logika template, dengan dukungan untuk kondisional dasar hingga yang kompleks. Sistem ini mendukung tiga mode: mode standar, mode enhanced, dan mode stable yang dapat diaktifkan secara eksplisit.
enable_enhanced_conditionals()
{if user.is_logged_in}
Dashboard
{endif}
{if cart.items > 0}
{cart.items} items
{else}
Cart empty
{endif}
{if user.role == 'admin'}
Admin Panel
{elseif user.role == 'moderator'}
Mod Panel
{else}
User Panel
{endif}
{if status === 'active'}
Active User
{endif}
{if role !== 'guest'}
Member Content
{endif}
{if user.age >= 18}
Adult Content
{endif}
{if stock < 10}
Low Stock Warning
{endif}
Enhanced conditionals menyediakan fitur yang lebih powerful dan fleksibel. Aktifkan dengan enable_enhanced_conditionals()
.
{if (user.age >= 18 && user.verified) || (user.has_parent_consent && user.parent_verified)}
Content Available
{endif}
{if user.subscription.status === 'active' && (user.credits > 100 || user.is_premium)}
Premium Features Available
{endif}
{if user.points === 100 && typeof(user.rank) === 'string'}
Rank: {user.rank}
{endif}
{if in_array(user.role, ['admin', 'moderator', 'supervisor'])}
Staff Access Granted
{endif}
Stable conditionals menyediakan evaluasi yang lebih reliable dan konsisten.
{if isset(user.preferences) && user.preferences.theme !== null}
Theme: {user.preferences.theme}
{endif}
{if user.id === '123'}
Exact Match
{endif}
{if is_numeric(user.id) && is_string(user.name)}
Valid User Data
{endif}
{if can_access_feature('premium_content')}
Premium Content Here
{endif}
NexaDom menyediakan tools untuk debugging kondisional:
{debug_condition("user.role === 'admin' && user.is_active")}
{debug_condition("(user.age >= 18 && user.verified) || user.has_parent_consent")}
{debug_switch user.status}
{case 'active'}
Active User
{endcase}
{case 'pending'}
Pending User
{endcase}
{endswitch}