Skip to content

Include File Content

tmpmachine edited this page Jul 13, 2021 · 3 revisions

Example

Easily include file content in another file with reserved <file> tag. This is the default preview behavior and currently there's no way to disable it.

<file src="data.json"></file>
<file src='response.json'></file>

Below snippet is also valid. You can include other file anywhere in your code.

<script>
  let gameData = <file src="data.json"></file>;
</script>

Relative File Path

File path is relative to file that's calling the <file> tag. Consider the following example :

Example directory structure :

|- index.html
|- view/
|---- modals.html
|---- template.html

Insert file content of view/modals.html in index.html.

<!-- index.html relative path -->
<file src="view/modals.html"></file>

Insert file content of view/template.html in view/modals.html.

<!-- modals.html relative path -->
<file src="template.html"></file>

File Content Loading Order

Codetmp will scan to the last file which is included by <file> tag then starts replacing content up to the parent file.

Clone this wiki locally