0

I'm working on the javascript templating system. I successfully created an x-magento-template (see here)

But I still don't understand how magento work with it internaly.

My template looks like that :

<script id="custom-option-select-type-row-template" type="text/x-magento-tmpl">
    <% console.log(data) %>
</script>

And produce this result :

Object { id: "1", option_type_id: -1, select_id: 1, sku: "", price: "" }

The script as the id of an existing template in Magento\Catalog module.

I didn't find in magento code any :

mageTemplate("#custom-option-select-type-row-template");

So, how magento can fill the "data" object and find the template to call ?

I want to be able to add my own parameter in this object.

0

Magento use mageTemplate component. See it in

lib\web\mage\template.js

to parse template inside script type text/x-magento-template with underscore lib helps
Data stored in input hidden somewhere used to pass through template

1
  • All I see in the template.js is the return function taking tmpl and data in parameter. That means there is another component in charge of finding the script id and parsing its content. By the way I would appreciate if you could give me a basic example of the use of the input type hidden in order to retrieve information in the template. I had no success with it. – Plup Mar 30 '16 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.