Files
rspade_system/app/RSpade/Integrations/Jqhtml/Jqhtml_View_Component.php
root f6fac6c4bc Fix bin/publish: copy docs.dist from project root
Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 02:08:33 +00:00

57 lines
1.5 KiB
PHP
Executable File

<?php
/**
* CODING CONVENTION:
* This file follows the coding convention where variable_names and function_names
* use snake_case (underscore_wherever_possible).
*/
namespace App\RSpade\Integrations\Jqhtml;
use Illuminate\View\Component;
use RuntimeException;
use App\RSpade\Integrations\Jqhtml\Jqhtml;
/**
* Generic Blade component for rendering jqhtml components
*
* Usage: <x-jqhtml component="User_Card" :args="['name' => 'Jim']" />
*/
#[Instantiatable]
class Jqhtml_View_Component extends Component
{
public string $component;
public array $args;
/**
* Create a new component instance
*
* @param string $component The jqhtml component name (e.g., 'User_Card')
* @param array $args Component arguments
*/
public function __construct(string $component, array $args = [])
{
// Validate component name starts with uppercase
if (!ctype_upper($component[0])) {
throw new RuntimeException(
"JQHTML component name '{$component}' must start with an uppercase letter. " .
'This is a hard requirement of the jqhtml library.'
);
}
$this->component = $component;
$this->args = $args;
}
/**
* Get the view / contents that represent the component
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
// Use the existing Jqhtml helper to render the component
return Jqhtml::component($this->component, $this->args);
}
}