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

Using Twig Templates #17

Open
MagePsycho opened this issue Nov 13, 2020 · 4 comments
Open

Using Twig Templates #17

MagePsycho opened this issue Nov 13, 2020 · 4 comments

Comments

@MagePsycho
Copy link

I think it's better to use Twig templating based generator.
This way, you can leverage the whole file with just a dynamic placeholder.

@luckyraul
Copy link
Contributor

luckyraul commented Nov 13, 2020

Escape PHP code in twig ? It's definitely tough task. We prefer to do it generate code, not to template it

@MagePsycho
Copy link
Author

Escape PHP code in twig ? It's definitely tough task. We prefer to do it generate code, not to template it

You can use any file and can use twig variable to replace with values.
For example, Magento's etc/module.xml twig template may look like

<?xml version="1.0"?>
<!--
{{ phpdoc_header }}
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="{{ Vendor }}_{{ Module }}" setup_version="{{ version }}">
        <sequence>
{% if 'payment' in templates %}
            <module name="Magento_Checkout"/>
            <module name="Magento_Sales"/>
            <module name="Magento_Quote"/>
{% endif %}
{% if 'import' in templates %}
            <module name="Magento_ImportExport" />
{% endif %}
        </sequence>
    </module>
</config>

@luckyraul
Copy link
Contributor

luckyraul commented Nov 13, 2020

How can i deal with merging XML Nodes from different entities?

@MagePsycho
Copy link
Author

How can i deal with merging XML Nodes from different entities?

Why you need that? That Magento system will do it.

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

No branches or pull requests

2 participants