Skip to main content

HotFile

hotstaq / Modules / HotFile

Class: HotFile

A file to process.

Implements​

  • IHotFile

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new HotFile(copy?)

Parameters​

NameType
copyIHotFile

Defined in​

HotFile.ts:70

Properties​

content​

• content: string

The content of the file to process.

Implementation of​

IHotFile.content

Defined in​

HotFile.ts:64


localFile​

• localFile: string

The path to the local file to get.

Implementation of​

IHotFile.localFile

Defined in​

HotFile.ts:60


name​

• name: string

The name of the file.

Implementation of​

IHotFile.name

Defined in​

HotFile.ts:52


page​

• page: HotPage

The parent page.

Implementation of​

IHotFile.page

Defined in​

HotFile.ts:48


throwAllErrors​

• throwAllErrors: boolean

Force all errors to be thrown.

Implementation of​

IHotFile.throwAllErrors

Defined in​

HotFile.ts:68


url​

• url: string

The url to the file to get.

Implementation of​

IHotFile.url

Defined in​

HotFile.ts:56

Methods​

getContent​

â–¸ getContent(): string

Get the content of this file.

Returns​

string

Defined in​

HotFile.ts:91


load​

â–¸ load(): Promise<string>

Load the contents of the file.

Returns​

Promise<string>

Defined in​

HotFile.ts:154


loadLocalFile​

â–¸ loadLocalFile(): Promise<string>

Load content from a local file.

Returns​

Promise<string>

Defined in​

HotFile.ts:131


loadUrl​

â–¸ loadUrl(): Promise<string>

Load content from a url.

Returns​

Promise<string>

Defined in​

HotFile.ts:121


process​

â–¸ process(args?): Promise<string>

Process the content in this file. This treats each file as one large JavaScript file. Any text outside of the <* *> areas will be treated as:

    Hot.echo ("text");

fixme The regex's in the offContent functions need to be fixed. There's several test cases where they will fail.

Parameters​

NameTypeDefault value
argsanynull

Returns​

Promise<string>

Defined in​

HotFile.ts:330


setContent​

â–¸ setContent(content): void

Set the content of this file.

Parameters​

NameType
contentstring

Returns​

void

Defined in​

HotFile.ts:83


httpGet​

â–¸ Static httpGet(url): Promise<string>

Make a HTTP get request.

Parameters​

NameType
urlstring

Returns​

Promise<string>

Defined in​

HotFile.ts:99


processContent​

â–¸ Static processContent(content, contentRegex, contentProcessor, offContentProcessor, numRemoveFromBeginning?, numRemoveFromEnd?): string

Process string content. This will take in a regular expression and parse the content based on the regex. When the regex content is found contentProcessor will be executed with the regex content found. When the regex content is not found, offContentProcessor will be called with the content outside of the regex.

Parameters​

NameTypeDefault valueDescription
contentstringundefinedThe content to parse.
contentRegexRegExpundefinedThe regex to use to parse the content.
contentProcessor(regexFound: string) => stringundefinedThe content found inside the regex.
offContentProcessor(offContent: string) => stringundefinedThe content found outside of the regex.
numRemoveFromBeginningnumber2The number of characters to remove from the beginning of the found content.
numRemoveFromEndnumber2The number of characters to remove from the end of the found content.

Returns​

string

Defined in​

HotFile.ts:183


processNestedContent​

â–¸ Static processNestedContent(content, startChars, endChars, triggerChar, contentProcessor, offContentProcessor, numRemoveFromBeginning?, numRemoveFromEnd?): string

Process any content that could have nested values. This will take in a regular expression and parse the content based on the regex. When the regex content is found contentProcessor will be executed with the regex content found. When the regex content is not found, offContentProcessor will be called with the content outside of the regex.

fixme Needs to be able to ignore any characters found inside comments or a string. For example, if the following is used ${"Test }"} It will error out.

Parameters​

NameTypeDefault valueDescription
contentstringundefinedThe content to parse.
startCharsstringundefined-
endCharsstringundefined-
triggerCharstringundefined-
contentProcessor(regexFound: string) => stringundefinedThe content found inside the regex.
offContentProcessor(offContent: string) => stringundefinedThe content found outside of the regex.
numRemoveFromBeginningnumber2The number of characters to remove from the beginning of the found content.
numRemoveFromEndnumber1The number of characters to remove from the end of the found content.

Returns​

string

Defined in​

HotFile.ts:241