Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render a Macro in a Template #23

Closed
wants to merge 1 commit into from
Closed

Conversation

frost-byte
Copy link

@frost-byte frost-byte commented Jan 15, 2017

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.

Add renderTemplateMacro to Twig wrapper
Update README
Update Unit tests
@kenjis
Copy link
Owner

kenjis commented Feb 2, 2017

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?

@frost-byte
Copy link
Author

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.

@kenjis
Copy link
Owner

kenjis commented Feb 3, 2017

@frost-byte

  1. Create your Twig library which extends Twig class in this repository.
  2. Use your own Twig library.

For example:
1.

require_once __DIR__.'/Twig.php';

class My_twig extends Twig
{
    public function renderTemplateMacro($view, $macro, $params = [])
    {
        ...
    }
}
$this->load->library('my_twig');

@frost-byte
Copy link
Author

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.)

@kenjis
Copy link
Owner

kenjis commented Feb 3, 2017

@frost-byte I guess so. Why do you want to access the private properties?

@frost-byte
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants