Closed frost-byte closed 7 years ago
In my understanding, macro is a function used in templates. So I don't want to merge this PR.
How about extending Twig
library for your use case?
That's fine, I'm looking in how to use my fork via composer. I suppose that means that I'll need to watch your repo and merge in any releases you make.
@frost-byte
For example: 1.
require_once __DIR__.'/Twig.php';
class My_twig extends Twig
{
public function renderTemplateMacro($view, $macro, $params = [])
{
...
}
}
2.
$this->load->library('my_twig');
Thanks, that works.
Though, I can't access the private properties of the Twig class. I guess I'm just supposed to call getTwig in any class that extends yours? (Otherwise you'd have to make them protected properties.)
@frost-byte I guess so. Why do you want to access the private properties?
That was meant as an aside. It's not necessary. But, it seemed strange for an extended class to call a getter of its parent. (I needed access to the twig property)
Add renderTemplateMacro to Twig wrapper Update README
I needed to update a view using an ajax call; this allows you to just run a macro from a template.