HashScript
is a simple and powerful scripting language created by @wwdenis and written in .NET.
While there are so many scripting engines, most require a certain learning curve.
HashScript
is intended to be lightweight, easy to learn, and still powerful.
- Detailed Documentation
- Visual Studio Code Formatter (and other IDE's)
- Custom Data Sources
Everything surrounded with a Hash symbol ( #
), is a Template Field, or just a Field
.
A field is a placeholder for a dynamic content.
HashScript
gieto be lightweight, easy to learn, and still powerful.
Symbol | Description |
---|---|
# | Indicates a Field |
+ | Indicates a Structured Field (inside a field) |
? | Indicates a Conditional Field (inside a field) |
! | Indicates a Conditional Field (inside a field, negate) |
. | Indicates a Function Field or a Value Field |
Type | Example | Note |
---|---|---|
Content Field | #Foo# |
A placeholder to render data. |
Structured Field | #+Foo# Text #+# |
Renders data below the data structure |
Confitional Field | #?Foo# Text #?# |
Renders when condition is True (use ! for False ) |
Function Field | #?.Foo# Text #?# |
Renders when the function Foo is True |
Value Field | The Numbers are #.# |
Renders the value of a item in a collection |
Conditional Field
is very flexible and can work with the followiung data types:
- Boolean:
True
orFalse
- Number:
True
when greather than Zero - Text:
True
when it has length - Collection:
True
when it has items - Object:
True
when the value is notnull
Function Field
is used to give the Renderer additional data.
For example, in the ObjectValueProvider
the following functions are defined:
- .First: Returns
True
when the item is the first in the colection - .Last: Returns
False
when the item is the last in the colection
#+Items#
#?.First# Foo #?#
#+#
Type |
Template |
Input |
Output |
Content Field |
|
{ "Name": "HashScript" } |
|
Structured Field (Complex Object) |
|
{ "Message": {
"Greeting": "Hello",
"Name": "HashScript"
}
} |
|
Structured Field (Collection) |
|
{ "Languages": [
{ "Name": "HZ", "Year": "2022" },
{ "Name": "VB", "Year": "1964" },
{ "Name": "CS", "Year": "2000" }
]} |
|
Conditional Field (Boolean) |
|
{
"IsDoctor": false,
"Name": "Denis"
} |
|
Conditional Field (Text, Number) |
|
{
"Name": "Denis",
"Email": "denis@hashscript.org",
"Address": "",
"Posts": 10
} |
|
Conditional Field (Collection) |
|
{
"Messages": []
} |
|
Conditional Field (Value) |
|
{
"Value": null
} |
|
Special Function |
|
{ "Languages": [
{ "Name": "HZ" },
{ "Name": "VB" },
{ "Name": "CS" }
]} |
|