DocsCLIPlaygroundAbout

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 our config json file to your root directory. Then all that's required is > fthtml convert from your root directory where it will use the configurations 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:

settingdatatypedescription
rootDirstringThe directory that searches for .ftHTML files. This should be relative to the root dir (where the fthtmlconfig.json file) is located.
exportDirstringThe directory where the converted files are exported to.
Same as > fthtml convert --dest
importDirstringThe directory where your import files are located. This makes the 'import' call relative from this directory instead of it's current working directory
templateDirstringThe directory where your templates are located. This makes the 'template' call relative from this directory instead of it's current working directory
keepTreeStructurebooleanKeeps the tree structure of rootDir.
Same as > fthtml convert --keep-tree
excludedstring[]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' and 'test' directories are excluded.
Same as > fthtml convert -e -- []

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

  • --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)