These are the template files shared and used by our loop creator tools, such as:
- Our
@oliveai/create-loop
npx command - Our VSCode extension
While anybody can technically install this library, it's really only useful to the tools above. If you're looking to create a loop from a template, we recommend using one of them!
- The template files make use of the Squirrelly template engine
and end with
.squirrelly
. - Every directory contains an
index.ts
containing afileMap
object.fileMap
objects follow this structure, where thekey
is the name of an imported template file or directory of templates:
{
[key: string]: {
fileName: string, // Name that the file should be given when rendered
aptitude: string, // An enum that determines which aptitudes will cause this to render
}
}
- The loop creators,
loop-creator-npx
andloop-creator-vscode
, recursively loop through thefileMap
objects in each directory and determine which files to render based on the aptitudes that the user selects.
- Node
- Check if you have it: run
node --version
in your terminal, should return a version number - If you don’t have it, use NVM
- Check if you have it: run
There is no VSCode extension for enabling syntax highlighting or other language features for Squirrelly template files. For creating templates, we've found the best luck with one of two methods:
- Write the "final" code as a standard TypeScript file, then change the file extension to Squirrelly and "template" the TypeScript syntax so it only renders if the user selects TypeScript.
- We recommend creating a JavaScript Loop to confirm you didn't miss any of the TypeScript syntax, as trying to build a JS file with TS syntax in it will immediately point it out.
- Put
<script>
at the top of the file and</script>
at the bottom, then change the language in VSCode to Handlebars. You can freely write JavaScript with templating and get syntax highlighting.
-
Make changes/additions to the template files and any relevant
fileMap
objects. -
Run
npm run build
to compile the templates into importable code. -
Move to the loop creator directory.
-
Update the dependency to point this project as a relative path. Example:
"dependencies": { ... "@oliveai/loop-templates": "file:../loop-creator-templates", ... }
-
Run
npm install
-
Run
npm run dev
-- this is effectively the same as runningnpx @oliveai/create-loop
but it's just using your local script instead of the script in the npm registry.
This will create a Loop with the changes you made in the templates.