In this example, we will show you how to use the CreativeEditor SDK’s CreativeEngine to apply the contents of a given template scene to the currently loaded scene through the scene
API.
Applying Template Scenes
applyTemplateFromString(content: string): Promise<void>
Applies the contents of the given template scene to the currently loaded scene. This loads the template scene while keeping the design unit and page dimensions of the current scene. The content of the pages is automatically adjusted to fit the new dimensions.
content
: The template scene file contents, a base64 string.- Returns A Promise that resolves once the template was applied or rejects if there was an error.
applyTemplateFromURL(url: string): Promise<void>
Applies the contents of the given template scene to the currently loaded scene. This loads the template scene while keeping the design unit and page dimensions of the current scene. The content of the pages is automatically adjusted to fit the new dimensions.
url
: The url to the template scene file.- Returns A Promise that resolves once the template was applied or rejects if there was an error.
get(): DesignBlockId | null
Return the currently active scene.
- Returns The scene or null, if none was created yet.
Full Code
Here’s the full code:
engine.scene.applyTemplateFromString('UBQ1ewoiZm9ybWF0Ij...');engine.scene.applyTemplateFromURL( 'https://cdn.img.ly/assets/demo/v1/ly.img.template/templates/cesdk_postcard_1.scene',);engine.scene.get();