{#if info:devQuteInfos.templates.isEmpty} {#include main} {#body}

No Templates found

{/body} {/include} {#else} {#include main} {#title}Render Preview{/title} {#style} .CodeMirror { height: auto; border: 1px solid #ddd; } #template-source-pre { margin: 0px; } {/style} {#styleref} {/styleref} {#body}

            
{/body} {#scriptref} {/scriptref} {#script} const templateSelect = document.querySelector('#template-select'); const templateDataMap = new Object(); const templateSourceMap = new Object(); {! Init the template path -> initial data map !} {#for template in info:devQuteInfos.templates} var testData{template_count}; {#if template.parameters} testData{template_count} = '{'; {#each template.parameters} testData{template_count} += '\n // Template parameter {it_count}: {it.value.raw}\n'; testData{template_count} += ' "{it.key}" : null'; {#if it_hasNext} testData{template_count} += ','; {/if} {/each} testData{template_count} += '\n}'; {#else} testData{template_count} = '{}'; {/if} {#each template.variants} templateDataMap['{it.key}'] = testData{template_count}; templateSourceMap['{it.key}'] = '{it.value}'; {/each} {/for} const editor = CodeMirror.fromTextArea(document.querySelector('#template-data'), { mode: { name: "javascript", json: true }, styleActiveLine: true, lineNumbers: true, lineWrapping: true, extraKeys: {"Ctrl-Space": "autocomplete"} }); const initialTemplate = '{info:devQuteInfos.templates.get(0).variants.keySet.iterator.next}'; editor.setValue(templateDataMap[initialTemplate]); document.querySelector('#template-source-pre').innerHTML = templateSourceMap[initialTemplate]; document.querySelector('#template-select').value = initialTemplate; editor.on("blur", function(codeMirror) { codeMirror.save(); }); editor.refresh(); templateSelect.addEventListener('input', (event) => { // Update the template data const templateData = document.querySelector('#template-data'); editor.setValue(templateDataMap[event.target.value]); editor.refresh(); // Update the list of expressions document.querySelector('#template-source-pre').innerHTML = templateSourceMap[event.target.value]; }); {/script} {/include} {/if}