main
Robert 5 months ago
parent e1c1a86424
commit 9bdb91a23e
  1. 2
      .gitignore
  2. 6
      protected/src/composer.json
  3. 2
      protected/src/configs/on_view_mode.php
  4. 24
      protected/src/controllers/app/home_ctrl.php
  5. 15
      protected/src/services/on_liquid.php
  6. 15
      protected/src/services/on_twig.php
  7. 14
      protected/src/views/liquid/app/liquid.tpl
  8. 11
      protected/src/views/twig/app/test.twig

2
.gitignore vendored

@ -2,8 +2,10 @@ protected/FWCodeHydrater
protected/src/secret_php_files
protected/src/aes
protected/src/aeskeys.php
protected/src/vendor
protected/keydata
protected/runtime
protected/logs
protected/src/composer.lock
*.swp
*.log

@ -0,0 +1,6 @@
{
"require": {
"twig/twig": "^3.0",
"liquid/liquid": "^1.4"
}
}

@ -5,5 +5,5 @@ declare(strict_types=1);
use CodeHydrater\bootstrap\configure as Config;
Config::set('view_mode', array(
'default_paths' => array('json', 'common', 'flexbox', 'default')
'default_paths' => array('json', 'common', 'flexbox', 'default', 'twig', 'liquid')
));

@ -9,6 +9,9 @@ declare(strict_types = 1);
*/
namespace Project\controllers\app;
use CodeHydrater\enums\view_type as ViewType;
use CodeHydrater\bootstrap\registry as Reg;
/**
* Description of home_ctrl
*
@ -19,17 +22,28 @@ class home_ctrl {
public function index() {
$html = new \CodeHydrater\html_document();
$html->set_author("Robert Strutts, plus ME!");
$view = new \CodeHydrater\view();
$view->set('html', $html);
$view->set_template('main');
$view->include("app/header");
$view->include("app/footer");
$view->render($this, "app/home_index");
$view->include("app/header", ViewType::PHP);
$view->include("app/footer", ViewType::PHP);
$view->render($this, "app/home_index", ViewType::PHP);
}
public function name_demo() {
echo "OLD DEMO Page...!";
$view = new \CodeHydrater\view();
$view->set('twig_data', ['name' => "John Doe"]);
$view->render($this, "app/test", ViewType::TWIG);
}
public function liquid() {
$view = new \CodeHydrater\view();
$view->set('template_assigns', [
'name' => "James Smith",
'date' => date('Y-m-d')
]);
$view->render($this, "app/liquid", ViewType::LIQUID);
}
public function extra() {

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
/**
* @author Robert Strutts <Bob_586@Yahoo.com>
* @copyright (c) 2025, Robert Strutts
* @license MIT
*/
use CodeHydrater\bootstrap\registry as Reg;
Reg::get('di')->register('liquid', function() {
return new \CodeHydrater\services\liquid_templates();
});

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
/**
* @author Robert Strutts <Bob_586@Yahoo.com>
* @copyright (c) 2025, Robert Strutts
* @license MIT
*/
use CodeHydrater\bootstrap\registry as Reg;
Reg::get('di')->register('twig', function() {
return \CodeHydrater\services\twig::init();
});

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Liquid Example</title>
</head>
<body>
<h1>Hello, {{ name }}!</h1>
<p>Today is {{ date }}.</p>
{% if name.size > 0 %}
<p>Your name has {{ name.size }} characters.</p>
{% endif %}
</body>
</html>

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Twig Example</title>
</head>
<body>
<h1>Hello, {{ name }}!</h1>
<p>Welcome to our website.</p>
<p>Twig Demo Page.</p>
</body>
</html>
Loading…
Cancel
Save