egoist/maid

Global Variables

raguay opened this issue ยท 8 comments

In a maidfile, it would be nice to have some variables set so that they can be referenced in the other scripts. Therefore, if the following was at the top:

## global

```bash
destdir='~/.dest'
```

```js
 var destdir='~/.dest'
```

Then the variable $destdir can be used in all the other bash scripts. Have the same thing for js scripts also.

The four spaces won. Using 4 tick didn't help.

saadq commented

Just as an FYI, you can indent each line with 4 spaces instead of using the 3 ` notation.

## global

```bash
destdir='~/.dest'
```

```js
 var destdir='~/.dest'
```

or use 4 backticks for the markdown block if you want syntax highlighting:

carbon 45

Probably a bit related to the #6. If we implement it with VM, we can pass process to the executed context, so if we define in bash i believe we can later access it in another js task from the process.env.

My idea was to just append the global section to the other scripts according to language. That way, it can setup a global function as well that is used in the other scripts. Much easier to implement than passing total environments from one process to another.

A shared global section that allows basic data types to be used in all language blocks would be very useful here.

(in addition to the original proposal for language-specific globals)


EG:

## global

```variables
destdir='~/.dest'
```

instead of

## global

```bash
destdir='~/.dest'
```

```js
 var destdir='~/.dest'
```

Er, quick question, completely unrelated: @egoist , how did you create the code block image? I.e. this one?

Ah, yes; thanks for that! Much appreciated!