TekWizely / bash-tpl

A smart, lightweight shell script templating engine, written in Bash
MIT License
65 stars 4 forks source link

.INCLUDE directive inside a statement block? #19

Closed tmm1 closed 3 months ago

tmm1 commented 1 year ago

hi, thanks for a great project

i'm trying to use .INCLUDE inside a statement block but can't quite figure it out. is it supported?

tmm1 commented 1 year ago

I think the answer is no, as explained here:

the .INCLUDE directive is a 'compile-time' feature, but the % directive is a runtime feature

TekWizely commented 1 year ago

Hi @tmm1 you figured it out yes the issue is compiletime vs runtime.

You might also have a read here where the user uses bash-tpl as a static site generator tool.

I came up with a strategy (and a makefile) to host a directory of bash-tpl templates that all compile to a directory of .sh/source scripts and you include them using the source at runtime.

See if anything there might be useful and lemme know your thoughts!

Thanks for taking the time to report an issue and for your interest in my project!

-TW

TekWizely commented 1 year ago

Hey @tmm1 just checking in to see if you got my reply - lemme know if you wanna continue the discussion !

TekWizely commented 3 months ago

Hi @tmm1 I'm going to close this issue, but wanted to add one last comment.

I moved the Makefile example mentioned earlier into the Discussion area:

You can use a source path/to/file in your statement block to include a file at runtime. In the case for a template you would be sourcing the compiled template.

I am working on an idea to add a .SOURCE directive for sourcing other compiled templates that could easily send the current line indent information along so that output generated from the sourced template would be consistent.

Thanks again for your interest in my project and taking the time to report an issue.

-TW