Extends
- Adapter
Methods
childNodeRange(node, childName) → {Object}
Get the source range of child node.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
node |
Node
|
The node. |
childName |
string
|
The name to find child node. |
Throws:
-
if we can't get the range.
- Type
-
NotSupportedError
Returns:
- Type:
-
Object
The range of the child node, e.g. { start: 0, end: 10 }
Example
const node = gonzales.parse("a { color: red }")
childNodeRange(node, "{{block.declaration.value}}") // { start: "a { color: ".length, end: "a { color: red".length }
childNodeValue(node, childName) → {any}
Get the value of child node.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
node |
Node
|
The node to evaluate. |
childName |
string
|
The name to find child node. |
Returns:
- Type:
-
any
The value of child node, it can be a node, an array, a string or a number.
Example
const code = `
nav {
a {
color: red;
}
}
`;
const node = gonzales.parse(code, { syntax: "scs" });
childNodeValue(node, "ruleset.block.ruleset") // node["ruleset"]["block"]["ruleset"]
fileContent() → {string}
Get the source code of current file.
- Source:
Returns:
- Type:
-
string
source code of current file.