Repository navigation
Replies: 2 comments 9 replies
|
Hey @philnwoha! Welcome, and thanks for giving Templatical a look! 👋 I have a good news for you: you don't actually need npm for this. The distinction you spotted is real, I shipped a curated first-party CDN bundle for the editor because I has bunch of runtime dependencies, I want CDN editor to be drop-in for any app, even basic HTML page. But all importers, including Here's a quick version using plan <script type="module">
import { convertUnlayerTemplate } from 'https://cdn.jsdelivr.net/npm/@templatical/import-unlayer@0.16.1/+esm';
// whatever your Unlayer editor returned from editor.saveDesign(...) OR saved design from your storage (DB)
const unlayerJson = await fetch('/path/to/unlayer-design.json').then(r => r.json());
const { content, report } = convertUnlayerTemplate(unlayerJson);
console.log(content); // → Templatical TemplateContent (feed straight into the editor)
console.log(report.summary); // → { total, converted, approximated, htmlFallback, skipped }
</script>From Blazor, via JS interop: // wwwroot/js/unlayerImport.js
import { convertUnlayerTemplate } from 'https://cdn.jsdelivr.net/npm/@templatical/import-unlayer@0.16.1/+esm';
export function convert(unlayerJson) {
return JSON.stringify(convertUnlayerTemplate(design)); // { content, report }
}var module = await JS.InvokeAsync<IJSObjectReference>("import", "./js/unlayerImport.js");
var json = await module.InvokeAsync<string>("convert", unlayerDesignJson);
// json → { "content": {...}, "report": {...} }; deserialize and store content.If this is a one-time migration of existing templates rather than a live in-app feature, you don't even need the interop wiring. The same call works in a throwaway script (or just paste your JSON into a small page using the first snippet). Would this work for you? Make sure to check And feel free to open an issue on this repo if something is not working as expected with importer. |
|
@orkhanahmadov thank you for the quick response. Unfortunately I still cannot get the code to work. Below is my javascript file using the default unlayer design json:
|



Uh oh!
There was an error while loading. Please reload this page.
Hi I recently discovered templatical and would like to make the switch from unlayer. Unlayer is fine but it is very expensive and my business is very small. My code stack is .net (specifically blazor). Rather than converting everyones json by hand, I would like to do it on the fly instead. The problem is it appears that the unlayer importer requires a npm installation (unlike the editor that can be loaded via cdn). Is it at all possible to the conversion without a reliance on npm?
All reactions