diff --git a/docs/examples/guess-the-number.md b/docs/examples/guess-the-number.md index 1ba672f..69ecf1e 100644 --- a/docs/examples/guess-the-number.md +++ b/docs/examples/guess-the-number.md @@ -1,8 +1,13 @@ # Guess The Number Game +Copy and paste the codeblock below into a new note to try it out. + ````md # Guess The Number Game + +This example plays the clasic guess the number game. You are told if your guess is too high, too low, or just right. + ```meld-build-toolbar run = Let The Games Begin help = @@ -12,7 +17,7 @@ help = const min = 1; const max = 100; -// choose a rundom number between min and max +// choose a random number between min and max const number = min + Math.round( Math.random() * (max-min) ); let guessCount = 0; diff --git a/docs/examples/invoice-builder.md b/docs/examples/invoice-builder.md index 3115d4c..eaaf1d8 100644 --- a/docs/examples/invoice-builder.md +++ b/docs/examples/invoice-builder.md @@ -1,12 +1,43 @@ # A Simple Invoice Builder +Copy and paste the codeblock below into a new note to try it out. + + ````md # A Simple Invoice Builder + +This example will produce and open an `HTML` file representing a simple invoice. From your default web browser, it can then be saved as a PDF. + +## Choose the invoice to build +```js meld-build +const invNumber = '22001'; +``` ```meld-build-toolbar run = Build the Invoice help = ``` +## The Data defined as JavaScript +```js meld-build +// Define the customers +const customers = [ + { id: 100, name: 'Some Co', address: ['123 Some Rd', 'Some City'] }, + { id: 101, name: 'Some Other Co', address: ['123 Some Other Rd', 'Some City'] }, +] + +// Define the invoices their lines +const invoices = [ + { + id: '22001', customer:100, date: '2022-12-01', status: 'open', + work: [ + { inv: '22001', date: '2022-11-13', start: 7.00, end: 16.50, rate: 25.45, desc: 'I did the thing' }, + { inv: '22001', date: '2022-11-16', start: 10.75, end: 12.00, rate: 25.45, desc: 'I did the other thing' }, + ] + }, +] + +``` + ## The invoice template ```html @@ -59,25 +90,8 @@ help = ``` -## The code to run +## The code to build the invoice ```js meld-build -const invNumber = '22001'; - -const customers = [ - { id: 100, name: 'Some Co', address: ['123 Some Rd', 'Some City'] }, - { id: 101, name: 'Some Other Co', address: ['123 Some Other Rd', 'Some City'] }, -] - -const invoices = [ - { - id: '22001', customer:100, date: '2022-12-01', status: 'open', - work: [ - { inv: '22001', date: '2022-11-13', start: 7.00, end: 16.50, rate: 25.45, desc: 'I did the thing' }, - { inv: '22001', date: '2022-11-16', start: 10.75, end: 12.00, rate: 25.45, desc: 'I did the other thing' }, - ] - }, -] - // get invoice to generate const inv = invoices.filter( e => e.id==invNumber ).at(0); // add line calculated fields diff --git a/docs/user-guide.md b/docs/user-guide.md index 3fe96c8..e1678ee 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -19,7 +19,7 @@ The `$` accessor provides a way to use the `meld-build` [API](api.md). Within the current note: - All tables are parsed and added to the `$.data` array. - All non-`meld-build` blocks are added to the `$.blocks` array. -- All `JavaScript` blocks with `meld-build` are concatenated, sandboxed and executed. +- `JavaScript` blocks with `meld-build` are concatenated, sandboxed and executed. ## Toolbar @@ -73,7 +73,7 @@ await $.ui.message( result ); Running this note will show a message with the following text: 'Greetings **John**, How are you?' -See the `$.io.import` and `$.io.load` API functions for other ways to load templates. +See the `$.io.import` and `$.io.load` [API](api.md) functions for other ways to load templates. ## Accessing the DataView plugin API