Skip to content

Commit

Permalink
Merge branch 'master' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
David Krause (enthus1ast) committed Aug 12, 2024
2 parents 2090e26 + b69fafe commit 7ef34bd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,34 @@ tests/basic/test_simple
tests/basic/test_while
src/nimja/parser
src/nimja/sharedhelper
tests/basic/NOT_READY_test_raw
tests/basic/test_endless_iterator
tests/basic/test_file_foo_html
tests/basic/test_iterator
tests/basic/test_lexer
tests/basic/test_module_import
tests/basic/test_nimjautils
tests/basic/test_proc
tests/basic/test_proc_import
tests/basic/test_scope
tests/basic/test_self
tests/basic/test_shorhands
tests/basic/test_strparse
tests/basic/test_tmplf_with_context
tests/basic/test_tmpls_with_context
tests/basic/test_tokens_before_extend
tests/basic/test_triple
tests/basic/test_unicode
tests/basic/test_when
tests/basic/test_whitespacecontrol
tests/basic/test_blockInBlock
tests/basic/test_blockNotExtendedMaster
tests/basic/test_blockRenderMasterDirectly
tests/basic/test_case
tests/basic/test_condense_strings
tests/basic/test_double_extend
tests/basic/test_doublicated_blocks
tests/basic/theModule/theModule
tests/bugs/test_nwt_bug4_debug
examples/prologue/serverPrologue
examples/prologue/serverJester
15 changes: 12 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ compileTemplateStr

```nim
proc myRenderProc(someParam: string): string =
compileTemplateStr("some nimja code {{someParam}}")
compileTemplateStr("some nimja code {{someParam}}", baseDir = getScriptDir())
echo myRenderProc("test123")
```
Expand All @@ -297,6 +297,8 @@ iteratior section.
assign calls to a variable. The default is `result`.
If you want it to use another variable set it in `varname`

`baseDir` is needed when you want to import/extend templates!

A context can be supplied to the `compileTemplateString` (also `compileTemplateFile`), to override variable names:

```nim
Expand Down Expand Up @@ -474,6 +476,9 @@ template and therefore can be included.

This way you create reusable template blocks to use all over your webpage.

(Since Nimja 0.9.0) If you import other templates, make sure to use the `baseDir` param with
`tmpls`, `tmplf`, `compileTemplateString` and `compileTemplateFile`.

partials/_user.nimja:
```twig
<div class="col-3">
Expand Down Expand Up @@ -501,6 +506,8 @@ a child template can extend a master template.
So that placeholder blocks in the master are filled
with content from the child.

(Since Nimja 0.9.0) If you extend other templates, make sure to use the `baseDir` param with
`tmpls`, `tmplf`, `compileTemplateString` and `compileTemplateFile`.

partials/_master.nimja
```twig
Expand Down Expand Up @@ -1113,14 +1120,16 @@ Changelog
- 0.9.0
- BREAKING CHANGE!
- in order to fix #15 & #89 and to enable nimja components imported from other modules,
all proc (`tmpls`, `tmplf`, `compileTemplateString` and `compileTemplateFile`) got an `baseDir` param:
all proc (`tmpls`, `tmplf`, `compileTemplateString` and `compileTemplateFile`) got a `baseDir` param:
```
compileTemplateStr("""{{importnimja "some/template.nimja"}}""", baseDir = getScriptDir())
tmpls("""{{importnimja "some/template.nimja"}}""", baseDir = getScriptDir())
compileTemplateFile("some/template.nimja", baseDir = getScriptDir())
tmpls("some/template.nimja", baseDir = getScriptDir())
```
The use of `tmplf(getScriptDir() / "foo.nimja")` is discourage. It could still work in some cirumstances though.
The use of `tmplf(getScriptDir() / "foo.nimja")` is discourage, use `tmplf("foo.nimja", baseDir = getScriptDir())` instead.
The old way could still work in some cirumstances though.
But its neccesary if you plan to import your nimja template code into other code.
- 0.8.7
- Removed unused `NImport`.
- Error on uneven `when` blocks.
Expand Down

0 comments on commit 7ef34bd

Please sign in to comment.