cachier-files
CachierFiles
Node.js file persistence manager that uses the file system for improved debugging/caching capabilities
Kind: global class
new CachierFiles([opts], [readFormatter], [writeFormatter], [log])
Constructor
| Param | Type | Description |
|---|---|---|
| [opts] | TemplateFileOpts | The TemplateFileOpts |
| [readFormatter] | function | The function(string, readFormatOptions) that will return a formatted string for reading data using the options.readFormatOptions from TemplateOpts as the formatting options. Typically reads are for HTML minification and/or beautifying. NOTE: Use with caution as syntax errors may result depending on the formatter used and the complexity of the data being formatted! |
| [writeFormatter] | function | The function(string, writeFormatOptions) that will return a formatted string for writting data using the options.writeFormatOptions from TemplateOpts as the formatting options. Typically reads are for JS minification and/or beautifying. NOTE: Use with caution as syntax errors may result depending on the formatter used and the complexity of the data being formatted! |
| [log] | Object | The log for handling logging output |
| [log.debug] | function | A function that will accept debug level logging messages (i.e. debug('some message to log')) |
| [log.info] | function | A function that will accept info level logging messages (i.e. info('some message to log')) |
| [log.warn] | function | A function that will accept warning level logging messages (i.e. warn('some message to log')) |
| [log.error] | function | A function that will accept error level logging messages (i.e. error('some message to log')) |
cachierFiles.metadata
Kind: instance property of CachierFiles
cachierFiles.readWriteNames
Kind: instance property of CachierFiles
cachierFiles.operations
Kind: instance property of CachierFiles
cachierFiles.register([read], [data], [read], [write]) ⇒ Object
Registers and caches the tempalte, one or more partials and/or context within the internal file system. Also creates any missing directories/sub-directories within the TemplateFileOpts outputPath directory from partialsPath sub-directories.
Kind: instance method of CachierFiles
Returns: Object - An object that contains the registration results:
dataThe object that contains the template, partial fragments and/or context that have been registerednameThe name that uniquely identifies the template, partial or contextcontentThe raw content of the template, partial or contextextensionThe template file extension designationparamsThe URLSearchParams passed during the initial content readfromReadA flag that indicates that the data was set from a read operationoverrideFromFileReadA flag that indicates if the passed partial content was overridden by content from a file read
dirsContains the directories/sub-directories that were created
| Param | Type | Description |
|---|---|---|
| [read] | Boolean | When true, an attempt will be made to also read any partials using option parameter |
| [data] | Array.<Object> | The template, partials and/or context to register. |
| partials[].name | String | The name that uniquely identifies the template, partial or context |
| [partials[].content] | String | The raw content that will be registered. Omit when read === true to read content from cache. |
| [partials[].params] | URLSearchParams | The URLSearchParams that will be passed during the content read (ignored when content is specified). |
| [partials[].extension] | String | Optional override for a file extension designated for a template, partial or context. |
| [read] | Boolean | When true, an attempt will be made to also Cachier.read the template, partials and context that do not have a content property set. |
| [write] | Boolean | When true, an attempt will be made to also Cachier.write the template, partials and context that have a content property set. |
cachierFiles.compile()
Kind: instance method of CachierFiles
cachierFiles.read()
Kind: instance method of CachierFiles
cachierFiles.write()
Kind: instance method of CachierFiles
cachierFiles.clear([all])
Clears the output directories and any file watchers
Kind: instance method of CachierFiles
| Param | Type | Default | Description |
|---|---|---|---|
| [all] | Boolean | false | true to clear all temporary directories created over multiple instances |