### Install pybars4
Source: https://github.com/up9inc/pybars4/blob/master/readme.md
Install the pybars4 library using pip.
```bash
pip install pybars4
```
--------------------------------
### Basic Template Rendering
Source: https://github.com/up9inc/pybars4/blob/master/readme.md
Demonstrates compiling a template string, defining custom helpers and partials, and rendering the template with provided data. Custom block helpers should accept 'this, options, *args, **kwargs'.
```python
# Get a compiler
from pybars import Compiler
compiler = Compiler()
# Compile the template
source = u"{{>header}}{{list people}}{{firstName}} {{lastName}}{{/list}}"
template = compiler.compile(source)
# Add any special helpers
def _list(this, options, items):
result = [u'
']
for thing in items:
result.append(u'- ')
result.extend(options['fn'](thing))
result.append(u'
')
result.append(u'
')
return result
helpers = {'list': _list}
# Add partials
header = compiler.compile(u'People
')
partials = {'header': header}
# Render the template
output = template({
'people': [
{'firstName': "Yehuda", 'lastName': "Katz"},
{'firstName': "Carl", 'lastName': "Lerche"},
{'firstName': "Alan", 'lastName': "Johnson"}
]}, helpers=helpers, partials=partials)
print(output)
```
--------------------------------
### Render Template with Custom Helper
Source: https://github.com/up9inc/pybars4/blob/master/readme.md
Demonstrates how to compile a Pybars template and render it using a custom helper function that returns a `strlist` for unescaped HTML output.
```python
import pybars
source = u"{{bold name}}"
compiler = pybars.Compiler()
template = compiler.compile(source)
def _bold(this, name):
return pybars.strlist(['', name, ''])
helpers = {'bold': _bold}
output = template({'name': 'Will'}, helpers=helpers)
print(output)
```
--------------------------------
### Run All Tests
Source: https://github.com/up9inc/pybars4/blob/master/readme.md
Execute all tests for the Pybars library using the provided test runner script.
```bash
python tests.py
```
--------------------------------
### Debug Pybars Tests
Source: https://github.com/up9inc/pybars4/blob/master/readme.md
Run the test suite with debug output enabled to inspect the Abstract Syntax Tree (AST) and generated Python code.
```bash
python tests.py --debug
```
--------------------------------
### Run Specific Test
Source: https://github.com/up9inc/pybars4/blob/master/readme.md
Execute a single, specific test case within the Pybars test suite.
```bash
python tests.py TestAcceptance.test_subexpression
```
--------------------------------
### Generated HTML Output
Source: https://github.com/up9inc/pybars4/blob/master/readme.md
The expected HTML output after rendering the template with the provided data, helpers, and partials.
```html
People
- Yehuda Katz
- Carl Lerche
- Alan Johnson
```
--------------------------------
### Debug Specific Test
Source: https://github.com/up9inc/pybars4/blob/master/readme.md
Run a specific test case with debug output enabled for detailed inspection.
```bash
python tests.py --debug TestAcceptance.test_subexpression
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.