Skip to content

Commit

Permalink
Merge pull request #6 from mbStavola/macro-support
Browse files Browse the repository at this point in the history
Add macros
  • Loading branch information
mbStavola authored Oct 29, 2020
2 parents 98bf634 + e322720 commit 3576150
Show file tree
Hide file tree
Showing 7 changed files with 417 additions and 145 deletions.
34 changes: 33 additions & 1 deletion SLY.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,36 @@ Boo!
---
```

Like slide scopes, the title text not used in processing.
Like slide scopes, the title text not used in processing.

## Macros

To cut down on repetition, Sly provides macro functionality.

```
green = (0, 255, 0);
$themeMacro = {
foo = "hello";
@font = "Fira Code";
# Can refer to outside variables
@fontColor = green;
# Variables only need to be instantiated
# by the time the macro is called, not when
# it is defined
@fontSize = defaultFontSize;
};
[Example Section]
defaultFontSize = 14;
# Will expand to the statement block originally
# defined in the macro
$themeMacro()
```

Macros are very basic in Sly. When called they simply expand to the statement block originally provided.

There is no concept of scope within a macro as each macro expansion is inlined.
72 changes: 59 additions & 13 deletions examples/basic.sly
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@ tealBlue = (78, 205, 196);
# of the presentation
@backgroundColor = coolGray;

@font = "Fira Code";
@fontSize = 42;
@fontColor = tealBlue;
@justify = "center";
$titleStyle = {
@font = "Fira Code";
@fontSize = 42;
@fontColor = tealBlue;
@justify = "center";
};

$contentStyle = {
@justify = "left";
@font = "Times New Roman";
@fontSize = 32;
@fontColor = paleGreen;
};

$titleStyle();

---
Welcome!
Expand All @@ -29,20 +40,14 @@ This is an example of Slydes
---

[First Slide]
@font = "Fira Code";
@fontSize = 42;
@fontColor = tealBlue;
@justify = "center";
$titleStyle();

---
Title Text
These are my thoughts
---

[[Body - Point 1]]
@justify = "left";
@font = "Times New Roman";
@fontSize = 32;
@fontColor = paleGreen;
$contentStyle();

---
- This is my first point
Expand All @@ -52,4 +57,45 @@ Title Text

---
- This is my second point
---

[Second Slide]
$titleStyle();

---
How about this?
---

[[Body 1]]
@justify = "right";
@font = "Times New Roman";
@fontSize = 38;
@fontColor = paleGreen;

---





I'm boldly making my point---

[[Body 2]]
@justify = "center";

---With some style---

[[Body 3]]
@justify = "left";

---What do you think?---

[Conclusion]
$titleStyle();

---



We're through
---
Loading

0 comments on commit 3576150

Please sign in to comment.