Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggested edits to data #95

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
"id": "mavoscript",
"advanced": false,
"title": "MavoScript",
"content": "Mavo’s **expression syntax** is called MavoScript. It is similar to spreadsheet formulas, but designed to be more readable and to accommodate nested relations (which spreadsheets cannot do).\n\nThey mostly consist of the following:\n\n# Property names\n\nYou use the value of a property you have defined by just typing its name. You can see some examples in the next section. You can use any property value from anywhere in your Mavo, or even in other Mavos (in that case, you'd need to add the app id before it, like `appid.propertyName`).\n\n##### Example\n\nMove the slider and check how both expressions are updated:\n\n```html\n<p>Slider value: [strength]/100</p>\n<input type=\"range\" property=\"strength\" title=\"[strength]%\" />\n```\n\nThe values of properties depend on where your expression is placed. When you use properties inside collections you get **all values** outside the collection, and **just the value of the current item** inside a collection item.\n\n# Function calls\n\nFunctions transform values into different values, for example they can do math on a number, or tell if you some text contains some other text. They are written with their name, and then a comma-separated list of parameters in parentheses, e.g. `min(2, 5)`.\n\n<p class=\"learn-more\">[All MavoScript functions](/docs/functions/?role=function)\n\n# Operators \n\nOperators are a shorter and more readable way to write common functions. For example, imagine if every time we wanted to subtract two numbers we had to write e.g. `subtract(2, 3)`. We would end up with a ton of parentheses for even simple expressions and it would be hard to understand what the expression actually does. Instead, we can write `2 - 3` instead, which is much shorter and more readable. Mavo supports all common math and logical operators, as well as some more like `where`.\n\n<p class=\"learn-more\">[All MavoScript operators](/docs/functions/?role=operator)\n\n# Special properties\n\nSpecial properties are available in every Mavo, and start with a dollar sign ($). They contain metadata, such as [the position of the current collection item (as a number starting from 0)](docs/functions/#$index) or [the current date/time](docs/functions/#$now). \n\n<p class=\"learn-more\">[All MavoScript special properties](/docs/functions/?role=special)\n\n# Raw data\n\nA lot of the data you will be using in expressions will come from your properties. However, sometimes you want to provide your own values as parameters. These can be:\n\n- **Numbers**, by just writing the number and using `.` as the decimal separator, e.g. `5` or `-0.3`. \n- The keyword `true` and the keyword `false` represent yes/no values. For example, `30 > 3` is equal to `true` because 30 is indeed larger than 3, and `3 > 30` is equal to `false` because 3 is not larger than 30.\n- Textual values, such as `\"cat\"` or `'Mary'`. You can use single quotes, double quotes, or even no quotes if the text contains only letters, numbers, and underscores. However, if you do that, beware of potential clashes with your property names!\n- Lists of values, just like those you get by referring a collection property from outside the collection, can be written as `list(value1, value2, value3, ...)`. You can read more about [`list()` here](/docs/functions/#list).\n- Grouped key-value pairs, just like the data you get when you reference a group can be created by using the `group()` function. E.g. `group(name: 'Vector', age: 12, hobby: list('Eating', 'Sleeping', 'Purring'))`\n\n"
"content": "Mavo’s **expression syntax** is called MavoScript. It is similar to spreadsheet formulas, but designed to be more readable and to accommodate nested relations (which spreadsheets cannot do).\n\nThey mostly consist of the following:\n\n# Property names\n\nYou use the value of a property you have defined by just typing its name. You can see some examples in the next section. You can use any property value from anywhere in your Mavo, or even in other Mavos (in that case, you'd need to add the app id before it, like `appid.propertyName`).\n\n##### Example\n\nMove the slider and check how both expressions are updated:\n\n```html\n<p>Slider value: [strength]/100</p>\n<input type=\"range\" property=\"strength\" title=\"[strength]%\" />\n```\n\nThe values of properties depend on where your expression is placed. When you use properties inside collections you get **all values** outside the collection, and **just the value of the current item** inside a collection item.\n\n# Function calls\n\nFunctions transform values into different values, for example they can do math on a number, or tell if you some text contains some other text. They are written with their name, and then a comma-separated list of parameters in parentheses, e.g. `min(2, 5)`.\n\nYou can also call a javascript function just as you’d call a Mavo provided function. It is advisable to add the defined js function on `Mavo.Functions` to guarantee it is always accessible. However, do note that when the parameters are other properties in Mavo, you are passing in objects and not primitive values. Unexpected behavior and bugs can arise if you pass in these Mavo objects to your js function without knowing such.\n\n<p class=\"learn-more\">[All MavoScript functions](/docs/functions/?role=function)\n\n# Operators \n\nOperators are a shorter and more readable way to write common functions. For example, imagine if every time we wanted to subtract two numbers we had to write e.g. `subtract(2, 3)`. We would end up with a ton of parentheses for even simple expressions and it would be hard to understand what the expression actually does. Instead, we can write `2 - 3` instead, which is much shorter and more readable. Mavo supports all common math and logical operators, as well as some more like `where`.\n\n<p class=\"learn-more\">[All MavoScript operators](/docs/functions/?role=operator)\n\n# Special properties\n\nSpecial properties are available in every Mavo, and start with a dollar sign ($). They contain metadata, such as [the position of the current collection item (as a number starting from 0)](docs/functions/#$index) or [the current date/time](docs/functions/#$now). \n\n<p class=\"learn-more\">[All MavoScript special properties](/docs/functions/?role=special)\n\n# Raw data\n\nA lot of the data you will be using in expressions will come from your properties. However, sometimes you want to provide your own values as parameters. These can be:\n\n- **Numbers**, by just writing the number and using `.` as the decimal separator, e.g. `5` or `-0.3`. \n- The keyword `true` and the keyword `false` represent yes/no values. For example, `30 > 3` is equal to `true` because 30 is indeed larger than 3, and `3 > 30` is equal to `false` because 3 is not larger than 30.\n- Textual values, such as `\"cat\"` or `'Mary'`. You can use single quotes, double quotes, or even no quotes if the text contains only letters, numbers, and underscores. However, if you do that, beware of potential clashes with your property names!\n- Lists of values, just like those you get by referring a collection property from outside the collection, can be written as `list(value1, value2, value3, ...)`. You can read more about [`list()` here](/docs/functions/#list).\n- Grouped key-value pairs, just like the data you get when you reference a group can be created by using the `group()` function. E.g. `group(name: 'Vector', age: 12, hobby: list('Eating', 'Sleeping', 'Purring'))`\n\n"
},
{
"id": "using-properties",
Expand Down