Overview
The entire purpose of the CLI is to make the process of converting files to static resources extremely easy and comfortable. You can convert a single file or an entire directory all at once!
It is recommended to install ftHTML globally to take advantage of the CLI.
> npm install -g fthtml
For those that don't know, installing globally allows you to use the module in any directory of your computer. This makes it easier to convert files from a single location instead of installing many copies of ftHTML through-out multiple projects.
fthtmlconfig.json
The fthtmlconfig.json file is used to expedite the CLI experience. Instead of typing a conversion process in your terminal every time you want to convert ftHTML files, you can add your configurations to the config json file in your root directory. Then, all that's required is running > fthtml convert from your root directory where it will use the configurations you've assigned in the fthtmlconfig.json file
fthtmlconfig.json
Easily convert your project, dir or file via CLI using our configuration file.
The config file has the same exact functionality as the CLI, with some additional features.
NOTE: When using vscode and when the ftHTML Languague extension is installed, suggestions and help tips populate to help you make a valid file so you don't have to remember the settings.
The configurations are as follows:
setting | datatype | description |
---|---|---|
excluded | string[] | An array of glob pattern directories to exclude from the rootDir search. We incorporated the glob package for this. You can review examples here. By default, 'node_modules', '.fthtml/imports' and 'test' directories are excluded. This property can be extended Same as > fthtml convert -e -- [] |
exportDir | string | The directory where the converted files are exported to. This property can be extended Same as > fthtml convert --dest |
extend | string[] | List of fthtmlconfig file paths that you can call to extend their properties. As of the Onyx update, this now includes remote HTTP configs |
globalvars | Object of string keys and string values | Assign global variables here so that you can easily call them from any file, without the 'vars' directive. These variables cascade and can therefore be over-written in any respective file as desired. This property can be extended |
globalTinyTemplates | Object of string keys and string values. ftHTML syntax is supported for the values | Assign global tiny templates here so that you can easily call them from any file, without the 'tinytemplates' directive. These templates cascade and can therefore be over-written in any respective file as desired. This property can be extended |
importDir | string | The directory where your import files or templates are located. This makes the 'import' call relative from this directory instead of it's current working directory. This property can be extended |
jsonDir | string | The directory where your json files are located. This makes the 'json' keyword call relative from the directory you provide, instead of it's current working directory. This property can be extended |
keepTreeStructure | boolean | Keeps the tree structure of rootDir.
Same as > fthtml convert --keep-tree |
prettify | boolean | By default, all ftHTML to HTML conversions are minified. You can optionally beautify it when converting using this flag.
Same as > fthtml convert --pretty |
rootDir | string | The directory that searches for .ftHTML files. This should be relative to the root dir (where the fthtmlconfig.json file) is located. This property can be extended |
convert
Convert a directory full of ftHTML files or a specific ftHTML file to HTML.
Syntax
convert <dir/file> [<...flags>]
Usage Notes
- Converting files will only look for ftHTML files in the specificed directory and no where else
- By default, 'node_module' and 'test' directories are omitted
Flags
-
-config
Specify an fthtmlconfig file path
Default
cwd
-
--dest
Export directory for all converted files
Default
Same directory as file/starting directory
Alias
-d
-
--exclude
The directories to exclude from querying for ftHTML files. (This does not exclude from parsing)
Default
[node_modules, test]
Alias
-e | -e --
-
--keep-tree
Keep the tree structure of the imported files when saved to export directory
Default
false
Alias
-k
-
--pretty
Exports the HTML syntax in a somewhat human readable format (not perfect, considering tags like 'pre' and 'code' preserve whitespace, but good for debugging)
Default
false
Alias
-p
-
--test
Provides an opportunity to visualize a convert without committing to it. This does everything a normal convert does, plus output the content, without actually exporting and saving to file[s]
Default
false
Alias
-t
--help
Shows respective help menu. Can intercept other flags
Alias
-h
--version
Shows version of CLI package.
Alias
-v
Assume the CWD (current working directory) is the root of your project.
Converting a file without any flags
> fthtml convert index.fthtml
Assume the CWD (current working directory) is the root of your project
Converting a directory without any flags
> fthtml convert ./.fthtml
Assume the CWD (current working directory) is the root of your project
Converting a directory to a specific directory
> fthtml convert ./.fthtml --dest ./
Please note: the export directory only contains 1 index.html (as shown in the HTML tab), even though contact\ has one as well. The file simply gets written over in this circumstance since keeping tree structure isn't honored, or specified.
Assume the CWD (current working directory) is the root of your project
Converting a directory to a specific directory [keeping tree structure]
> fthtml convert ./.fthtml --dest ./ --keep-tree
Assume the CWD (current working directory) is the root of your project
Converting a directory to a specific directory while excluding a directory [keeping tree structure]
> fthtml convert ./.fthtml --dest ./ -e imports
Please note: excluding a directory is only for exporting purposes (it does NOT exclude it from parsing or importing)
Assume the CWD (current working directory) is the root of your project
Converting a directory to a specific directory while excluding many directories [keeping tree structure]
> fthtml convert ./.fthtml -d ./ -k -e imports -e contact
> fthtml convert ./.fthtml -d ./ -k -e -- imports contact
repeat as many directories (seperated by a space)> fthtml convert ./.fthtml -d ./out -k --exclude -- imports contact
repeat as many directories (seperated by a space)