Created
June 9, 2025 05:12
-
-
Save derekmc/363573a7aca502e1e951206101deb5c0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#use jinja2 as a static site generator | |
import jinja2 | |
import shutil | |
import os | |
src_folder = 'src' | |
out_folder = 'out' | |
render_list = ['index.html'] | |
data_list = [{}] | |
def render(folder, filename, **data): | |
return jinja2.Environment( | |
loader=jinja2.FileSystemLoader(src_folder) | |
).get_template(filename).render(data) | |
def main(): | |
if(os.path.exists(out_folder)): | |
shutil.rmtree(out_folder) | |
os.mkdir(out_folder) | |
for filename, data in zip(render_list, data_list): | |
txt = render(src_folder, filename, **data) | |
path = os.path.join(out_folder, filename) | |
with open(path, 'w') as f: | |
f.write(txt) | |
main() |
This file contains hidden or 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
console.info("Hello, World in 'hello.js'") | |
console.info("Hello, World in 'hello.js'") | |
console.info("Hello, World in 'hello.js'") | |
console.info("Hello, World in 'hello.js'") |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title> Demo Static Page </title> | |
</head> | |
<body> | |
{{2**1000}} | |
<script> | |
{% include 'js/hello.js' %} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment