Constructor
new SFCData(filepath)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string | The file path of the component for which the data will be saved. This is later used when merging components in order to fix relative paths between files. |
Members
(nullable) baseFileData :SFCData
- Source:
In case the SFC extends another SFC, this will be a reference for it.
Type:
directory :string
- Source:
The directory where the SFC is located.
Type:
- string
extendTagAttributes :Object
- Source:
In case the SFC extends another SFC, this dictionary will contain the information of
the <extend />
tag.
Type:
- Object
filepath :string
- Source:
The path of the SFC.
Type:
- string
hasBaseFileData :boolean
- Source:
Whether or not the SFC extends another SFC.
Type:
- boolean
hasModuleScripts :boolean
- Source:
Whether or not the SFC has module script tags (those with the context="module"
attribute).
Type:
- boolean
hasScripts :boolean
- Source:
Whether or not the SFC has script tags.
Type:
- boolean
hasStyles :boolean
- Source:
Whether or not the SFC has style tags.
Type:
- boolean
markup :string
- Source:
The HTML markup of the SFC; this doesn't include scripts and styles.
Type:
- string
moduleScript :SFCTag
- Source:
A single SFCTag
that merges the contents and attributes of all the module
scripts tags (those with the context="module"
attribute) the SFC has.
Type:
moduleScripts :Array.<SFCTag>
- Source:
The list of module script tags (those with the context="module"
attribute) the SFC
has.
Type:
- Array.<SFCTag>
script :SFCTag
- Source:
A single SFCTag
that merges the contents and attributes of all the script
tags the SFC has.
Type:
scripts :Array.<SFCTag>
- Source:
The list of script tags the SFC has.
Type:
- Array.<SFCTag>
style :SFCTag
- Source:
A single SFCTag
that merges the contents and attributes of all the style tags
the SFC has.
Type:
styles :Array.<SFCTag>
- Source:
The list of style tags the SFC has.
Type:
- Array.<SFCTag>
Methods
addBaseFileData(fileData, extendTagAttributes)
- Source:
Adds the information of a SFC this one is extending.
Parameters:
Name | Type | Description |
---|---|---|
fileData |
SFCData | The SFC information. |
extendTagAttributes |
Object | The attributes of this SFC |
Throws:
-
-
If this SFC already has a base SFC already set.
- Type
- Error
-
-
-
If the
fileData
is not an instance ofSFCData
. - Type
- Error
-
addMarkup(content)
- Source:
Adds HTML markup for the SFC. If there's already markup saved, it will just append it.
Parameters:
Name | Type | Description |
---|---|---|
content |
string | The HTML code to add. |
addScript(content, attributes)
- Source:
Adds a script tag information to the SFC.
Parameters:
Name | Type | Description |
---|---|---|
content |
string | The contents of the tag. |
attributes |
Object | A dictionary with the tag attributes. |
addStyle(content, attributes)
- Source:
Adds a style tag information to the SFC.
Parameters:
Name | Type | Description |
---|---|---|
content |
string | The contents of the tag. |
attributes |
Object | A dictionary with the tag attributes. |
render() → {string}
- Source:
Renders the whole SFC information into a string, so it can be saved on a file.
Returns:
- Type
- string
(static) new(filepath) → {SFCData}
- Source:
A shorthand to create a new instance of the class.
Parameters:
Name | Type | Description |
---|---|---|
filepath |
string | The file path of the component for which the data will be saved. This is later used when merging components in order to fix relative paths between files. |
Returns:
- Type
- SFCData