voidlabs / mosaico

Mosaico - Responsive Email Template Editor
https://mosaico.io
GNU General Public License v3.0
1.7k stars 500 forks source link

Loading blocks-wysiwyg.tmpl.html #520

Closed QuietSpecialist closed 5 years ago

QuietSpecialist commented 5 years ago

Hi,

I'm struggling to understand how/when 'blocks-wysiwyg.tmpl.html' get's loaded. Where in the app is the code that does this please?

Thanks,

S

bago commented 5 years ago

You'll need a good Knockout knowledge and a lot of studying of Mosaico code to grasp this kind of stuff: why do you need this answer? Maybe you don't need to know that.

That said:

1) The templates are combined to a js file by grunt: https://github.com/voidlabs/mosaico/blob/master/tasks/combineKOTemplates.js This will call "templateSystem.addTemplate" for each template in that folder.

2) The templates are then included by Knockout using a directive that uses a template (ko template:, ko block:): you find most of them in the parser: https://github.com/voidlabs/mosaico/blob/master/src/js/converter/parser.js

3) The template file name is "template name"-"templateMode".tmpl.html: so a single template "name" may have different representation depending on the "templateMode": "wysiwyg" is the template used in the main working area of mosaico where you edit the template visually. "show" is the template used to render the same template in preview or for export. "edit" is the templateMode for the "Content" tab and "styler" is the templateMode for the "Style" tab for that element.

QuietSpecialist commented 5 years ago

Thanks for the detailed explanation Bago. I'm updating the front-end UI but want to avoid overwriting your template files, rather I'm just swapping them out for my versions. This was the only template file I couldn't find being referenced in the code.

Thanks again,

S