Suppose I have 3 files:
index.html
And here is foo:
<!-- include: includes/foo.html -->
This can be done similarly:
<code>
<!-- include: includes/bar.txt -->
</code>
includes/foo.html
FOO CONTENTS
FOO CONTENTS
FOO CONTENTS
includes/bar.txt
BAR CONTENTS
BAR CONTENTS
BAR CONTENTS
BAR CONTENTS
BAR CONTENTS
How can I replace the include
s automatically with a command like awk 'some magic code' index.html > compiled.html
?
compiled.html
And here is foo:
FOO CONTENTS
FOO CONTENTS
This can be done similarly:
<code>
BAR CONTENTS
BAR CONTENTS
BAR CONTENTS
BAR CONTENTS
BAR CONTENTS
</code>
Additional comments
- If no such file is found, a warning or error (preferred) should occur (
<!-- include: includes/does-not-exist.txt -->
) - The
<!-- include: ... -->
line must not be incompiled.html
- I am flexible on the
include
syntax. It could be<include "includes/foo.html">
if it's easier. - I want something like "pointer files", but without a hardcoded filename and without the pointer file line being included
- The command must not require me to manually specify all of the
include
s. (awk 'some magic code' index.html includes/foo.html includes/bar.txt > compiled.html
is not allowed) - It just needs to work on most filenames and should not require too many tools (for example, I'd rather not install PHP server just to use
<? include "includes/bar.txt" ?>
)
Template::Toolkit
. Is there less dependencies version? I do not understand your "is it paid task" question. – wjwrpoyob Mar 01 '23 at 19:13