-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from databio/dev
v1
- Loading branch information
Showing
42 changed files
with
912 additions
and
536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Variable variables for book demo | ||
|
||
This folder contains an example of how to write a generic jinja template, and encode the contents within data variables in the config file. | ||
|
||
There are three examples that produce the same output, which can be produced using these commands: | ||
|
||
``` | ||
mm -c book_basic/_markmeld.yaml default -p | ||
mm -c book_var1/_markmeld.yaml default -p | ||
mm -c book_var2/_markmeld.yaml default -p | ||
``` | ||
|
||
|
||
## Book basic | ||
|
||
This encodes the chapters directly in the `jinja` template. It's simple, but it's not re-usable. | ||
|
||
## Book var1 | ||
|
||
This method uses the `_md` array, and indexes into it with `data.variables` specified in the `_markmeld.yaml` file. This uses a jinja template that is reusable. | ||
|
||
## Book var2 (recommended) | ||
|
||
This way extracts the chapters out of the `_markmeld.yaml` config file into a standalone yaml file. This is the most flexible way, since both the `jinja` template can be reused, and the `target` could also be imported and re-used with a different `chapters.yaml` file. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
targets: | ||
default: | ||
jinja_template: book.jinja | ||
output_file: "demo_output.txt" | ||
command: cat > {output_file} | ||
data: | ||
md_files: | ||
intro: ../md/01-intro.md | ||
credit: ../md/02-credit.md | ||
savings: ../md/03-savings.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{ intro }} | ||
{{ credit }} | ||
{{ savings }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Introduction | ||
|
||
This is my introduction chapter | ||
|
||
... | ||
# Credit | ||
|
||
This is chapter 2 on credit. | ||
|
||
... | ||
# Chapter 3: Savings | ||
|
||
This is chapter 3 on savings. | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
targets: | ||
default: | ||
jinja_template: book.jinja | ||
output_file: "demo_output.txt" | ||
command: cat > {output_file} | ||
data: | ||
md_files: | ||
intro: ../md/01-intro.md | ||
credit: ../md/02-credit.md | ||
savings: ../md/03-savings.md | ||
variables: | ||
chapters: | ||
- intro | ||
- credit | ||
- savings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{% for chapter in chapters %}{{ _md[chapter] }} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Introduction | ||
|
||
This is my introduction chapter | ||
|
||
... | ||
# Credit | ||
|
||
This is chapter 2 on credit. | ||
|
||
... | ||
# Chapter 3: Savings | ||
|
||
This is chapter 3 on savings. | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
targets: | ||
default: | ||
jinja_template: book.jinja | ||
output_file: "demo_output.txt" | ||
command: cat > {output_file} | ||
data: | ||
md_globs: | ||
- ../md/*.md | ||
yaml_files: | ||
chapters: chapters.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{% for chapter in _yaml["chapters"] %}{{ _md[chapter] }} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- 01-intro | ||
- 02-credit | ||
- 03-savings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Introduction | ||
|
||
This is my introduction chapter | ||
|
||
... | ||
# Credit | ||
|
||
This is chapter 2 on credit. | ||
|
||
... | ||
# Chapter 3: Savings | ||
|
||
This is chapter 3 on savings. | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Introduction | ||
|
||
This is my introduction chapter | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Credit | ||
|
||
This is chapter 2 on credit. | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Chapter 3: Savings | ||
|
||
This is chapter 3 on savings. | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
version: 1 | ||
targets: | ||
basetgt: | ||
data: | ||
md_files: | ||
some_text_data: some_text.md | ||
default: | ||
inherit_from: basetgt | ||
command: cat > "{output_file}" | ||
output_file: "{_today}_demo_output_{recipient}.txt" | ||
loop: | ||
loop_data: recipients | ||
assign_to: recipient | ||
md_template: md_template.jinja | ||
jinja_template: md_template.jinja | ||
recursive_render: false | ||
data_yaml: | ||
- some_data.yaml | ||
data: | ||
yaml_globs_unkeyed: | ||
- some_data.yaml | ||
complex_loop: | ||
inherit_from: basetgt | ||
command: cat > "{output_file}" | ||
output_file: "{today}_demo_output_complex_{recipient[name]}.txt" | ||
jinja_template: md_template_complex.jinja | ||
recursive_render: false | ||
loop: | ||
loop_data: recipients | ||
assign_to: recipient | ||
md_template: md_template_complex.jinja | ||
recursive_render: false | ||
data_yaml: | ||
- complex_loop.yaml | ||
data_md: | ||
some_text_data: some_text.md | ||
data: | ||
yaml_globs_unkeyed: | ||
- complex_loop.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.