
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
trim-template
is an HTML templating engine for Python inspired by Ruby's Slim template engine.
The objective behind Trim is to simplify template syntax to a minimal format that, like Python itself,
makes use of indentation to indicate how blocks of code should be interpreted.
pip install trim-template
doctype strict
html
head
title My HTML title
stylesheet src='/some.css'
javascript:
console.log('embedded JS inside the template');
body
css:
.alert { color: 'red'; }
.menu-bar
- if user.logged_in
img src={user.profile.image_path}
- else
a#login-button.btn.btn-primary href={login_path} Login
.alert
h1 {greeting}
p.exciting This is the first ever Python Trim-Template
h2#member-list Members
form
input type='checkbox' disabled=True checked=True
p
ul
- for user in users
li
/ code comment - show the user's names. This line will not render.
span {user.first_name} {user.last_name}
/! render the footer
#footer Thanks for using Trim!
Trim-Template will render the above template into HTML, as below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>My HTML title</title>
<stylesheet src="/some.css"></stylesheet>
<script type='javascript'>
console.log('embedded JS inside the template');
</script>
</head>
<body>
<style>
.alert { color: 'red'; }
</style>
<div class="menu-bar">
<a class="btn btn-primary" href="/auth/login" id="login-button"/>Login</a>
</div>
<div class="alert">
<h1>Hello World!</h1>
</div>
<p class="exciting">
This is the first ever Python Trim-Template
</p>
<h2 id='member-list'>Members</h2>
<form>
<input type="checkbox" disabled="disabled" checked="checked"/>
</form>
<p>
<ul>
<li>
<span>Stephen Colber</span>
</li>
<li>
<span>Bob Marley</span>
</li>
<li>
<span>Charlie Chaplin</span>
</li>
</ul>
</p>
<!-- render the footer -->
<div id='footer'>Thanks for using Trim!</div>
</body>
</html>
from trim_template.trim import TrimTemplate
tmpl = TrimTemplate("file.html.trim")
tmpl.set('login_path', '/auth/login')
tmpl.set('greeting', 'Hello World!')
tmpl.set('users', users)
output = tmpl.render()
print(output)
Where file.html.trim
(also in the examples dir) contains the following.
Option | Values | Description |
---|---|---|
debug | all / tags | debug output format when calling tmpl.debug() |
pretty | True / False | output pretty HTML |
indentation | integer | depth of indentation for debugging output |
TrimTemplate
can be initialized with multiple parameters, the full set shown below:
tmpl = TrimTemplate('file.html.trim', pretty=True, debug='all', indent=4, vars={greeting: 'hello'})
See the USAGE markdown file for details on trim syntax and other usage.
Contributions are welcome. Fork the project and create a pull request.
David Kelly created the project in Feb 2024
FAQs
A templating engine inspired by Ruby's Slim template engine
We found that trim-template demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.