I am trying to use load_class to load mthaml as I understood this is necessary for performance reasons.
This is the MtHaml library. https://github.com/arnaud-lb/MtHaml
These names were everywhere, so getting it to work with load_class initially falls into the first hurdle. Then it is created through Autoloader.php, which makes
namespace MtHaml; class Autoloader { static public function register() { spl_autoload_register(array(new self, 'autoload')); } static public function autoload($class) { if (strncmp($class, 'MtHaml', 6) !== 0) { return; } if (file_exists($file = __DIR__ . '/../' . strtr($class, '\\', '/').'.php')) { require $file; } }
I'm trying to
load_class('Autoloader', 'libraries/MtHaml', '');
But it gives me a fatal error: Class 'Autoloader' not found
Then if I try
load_class('MtHaml\Autoloader', 'libraries/MtHaml', '');
I get Unable to find the specified class: MtHaml \ Autoloader.php
Right now, the only way I got this job is to call it like this
require_once __DIR__ . '/../libraries/MtHaml/Autoloader.php'; MtHaml\Autoloader::register(); $haml = new MtHaml\Environment('php'); $rendered = $haml->compileFile($haml_file, $haml_cache_path);
The problem is that this piece of code runs anytime when I call my view this this> load-> in a code igniter, so I realized that load_class is needed to optimize performance, as in one controller, I could call $ this-> load-> several times.
How to use load_class with this?