A powerful browser-based TTP (Template Text Parser) template editor that runs entirely client-side using Pyodide. This tool allows you to create, edit, and test TTP templates with advanced features like custom functions, lookup tables, and global variables.
- Client-side Processing: Runs entirely in the browser using Pyodide (WebAssembly Python)
- Monaco Editor: Professional code editing with syntax highlighting, auto-completion, and IntelliSense
- Multiple Output Formats: JSON, YAML, and table formats
- Multiple Named Inputs: Configure multiple inputs with template and group specifications
- Global Variables: Define reusable variables for templates
- Custom Functions: Create Python functions for advanced data processing
- Lookup Tables: Define lookup tables for data enrichment
- Pyodide Packages: Install additional Python packages from PyPI or custom URLs
- Export/Import: Save and share complete configurations as
.ttp.exportfiles - Workspace Management: Save, load, and manage multiple workspaces
- Real-time Processing: Auto-process templates as you type
- Error Marking: Visual error indicators in template editor
- Built-in Examples: Pre-loaded TTP templates for common use cases
- Resizable Panes: Adjustable editor panes for optimal workflow
- Professional UI: Modern dropdown menus, modals, and notifications
- TTP Syntax Highlighting: Custom syntax highlighting for TTP templates
- Auto-completion: Context-aware suggestions for TTP functions and Python built-ins
- A modern web browser with WebAssembly support
- Internet connection (for loading Pyodide and dependencies)
-
Local Development Server (recommended):
cd "TTP Editor" python3 -m http.server 8080
Then open http://localhost:8080 in your browser.
-
Direct File Access: You can also open
index.htmldirectly in your browser, though some features may be limited due to CORS restrictions.
- Load the Application: Open the website and wait for the Python runtime to initialize
- Input Data: Paste your raw text data in the left panel
- Create Template: Write or paste your TTP template in the middle panel
- Configure Inputs (optional): Click "Config" β "π₯ Inputs" to manage multiple named inputs
- Configure Variables (optional): Click "Config" β "Variables" to define global variables
- Add Custom Functions (optional): Click "Config" β "Functions" to create Python functions
- Define Lookup Tables (optional): Click "Config" β "Lookups" to create data lookup tables
- Install Packages (optional): Click "Config" β "π¦ Packages" to install additional Python packages
- Process: Click "Process" or enable auto-processing
- View Results: See parsed results in the right panel
- Export: Click "File" β "Export" to download results or save complete configuration
The application includes several built-in examples:
- Cisco Interface Configuration: Parse interface settings
- Routing Table: Extract routing information
- System Log Parsing: Parse various log formats
- Network Device Inventory: Extract device information
Click "Load Example" to try these templates.
Configure multiple inputs with different templates and groups:
- Click "Config" β "π₯ Inputs"
- Add inputs with unique names, template associations, and group filters
- Each input can target specific templates and process only certain groups
- Perfect for processing multiple data sources with different parsing rules
Example Input Configuration:
- Input Name:
router_config - Template:
_root_template_ - Groups:
interfaces,routing - Data: [Your router configuration data]
Define reusable variables that can be used in your templates:
- Click "Config" β "Variables"
- Enter variables in JSON, YAML, or Python dictionary format
- Use variables in templates with
{{ variable_name }}
Create Python functions for advanced data processing:
- Click "Config" β "Functions"
- Define function scope (match, group, input, output, etc.)
- Write Python code for your function
- Use functions in templates with
{{ data | my_function }}
Define lookup tables for data enrichment:
- Click "Config" β "Lookups"
- Create lookup tables in various formats (JSON, YAML, CSV, etc.)
- Use lookups in templates with
{{ data | lookup("table_name", "key") }}
Install additional Python packages to extend TTP functionality:
- Click "Config" β "π¦ Packages"
- Add packages by name (PyPI) or URL (wheel files)
- Packages are loaded when processing starts and cached in browser
- Important: Only pure Python packages are supported (no C extensions)
- Pure Python Only: Packages must be pure Python (no C extensions)
- Wheel Files: PyPI packages must be
-none-any.whlformat - Pyodide Compatible: Packages with C extensions need special Pyodide builds
β Compatible Examples:
requests- HTTP librarypyyaml- YAML parserjsonschema- JSON validationpython-dateutil- Date utilities
β Incompatible Examples:
numpy,pandas,scipy- Contain C extensionsmatplotlib,tensorflow- Require compiled librariesopencv-python,pillow- Image processing with C code
Example Package Configuration:
- Package Name:
requests(PyPI package) - Source Type: PyPI
- Package Name:
https://example.com/custom-package.whl(URL) - Source Type: URL
Save and share complete configurations:
- Export: Click "File" β "Export" to download
.ttp.exportfile - Import: Click "File" β "Import" to load configuration from file
- Workspace: Use "Workspace" β "Save"/"Load" for local workspace management
- Manage Workspaces: Click "Workspace" β "Manage" to organize saved workspaces
The application features a modern, organized interface:
- Main Actions: Process, Download, Output Format selector
- Actions Dropdown: Clear All, Load Example
- Config Dropdown: Inputs, Variables, Functions, Lookups, Packages
- File Dropdown: Export, Import
- Workspace Dropdown: Save, Load, Manage workspaces
- Auto-completion: Context-aware suggestions for TTP functions and Python built-ins
- Syntax Highlighting: Custom highlighting for TTP templates
- Professional Modals: Beautiful dialogs for configuration and management
Ctrl/Cmd + Enter: Process templateCtrl/Cmd + L: Load exampleCtrl/Cmd + K: Clear all inputsEscape: Close modals and dropdownsEnter: Save in modals
- Frontend: HTML5, CSS3, JavaScript (ES6+)
- Python Runtime: Pyodide v0.28.2 (WebAssembly)
- Text Processing: TTP (Template Text Parser) library
- Code Editor: Monaco Editor with custom TTP language support
- Styling: Modern CSS with dark theme, dropdowns, and modals
- Storage: LocalStorage for workspace persistence and URL sharing
- Sharing: Export/Import system with
.ttp.exportfiles - UI Components: Professional modals, dropdowns, and notifications
TTP Editor/
βββ index.html # Main application page
βββ css/
β βββ main.css # Application styles
βββ js/
β βββ app-monaco.js # Main application logic with Monaco Editor
β βββ ttp-processor.js # TTP processing wrapper
β βββ examples.js # Sample templates and data
βββ LICENSE # MIT License
βββ README.md # This file
- Chrome/Chromium 57+
- Firefox 52+
- Safari 11+
- Edge 16+
WebAssembly support is required for Pyodide to function.
TTP uses a template-based approach to parse text data. Here are some key concepts:
<template name="example">
<group name="items*">
{{ variable1 }} {{ variable2 }}
{{ variable3 | to_int }} {{ variable4 | re("\\d+") }}
</group>
</template>to_int: Convert to integerto_float: Convert to floatre("pattern"): Regular expression matchingcontains("text"): Check if text contains substringsplit("delimiter"): Split text by delimiter
group*: Multiple results (list)group: Single result (dict)group**: Nested groups
For more detailed TTP documentation, visit: https://ttp.readthedocs.io/
To add new examples, edit js/examples.js and add entries to the TTP_EXAMPLES object:
'new_example': {
name: 'Example Name',
data: 'Raw text data...',
template: 'TTP template...'
}The application uses CSS custom properties for easy theming. Main colors and styles are defined in css/main.css.
The modular architecture makes it easy to extend:
TTPProcessor: Handles Pyodide and TTP operations with multiple input supportTTPEditor: Manages UI, Monaco editors, modals, and user interactionsexamples.js: Contains sample data and templates- Monaco Editor: Professional code editing with TTP syntax highlighting and auto-completion
- Export/Import System: File-based configuration sharing with inputs support
- Modal System: Reusable modal components for configuration dialogs
- Dropdown System: Organized menu system for better UX
-
Slow Initial Load: Pyodide downloads ~10MB on first load. Subsequent loads are cached.
-
Memory Issues: Large datasets may cause memory issues. Try processing smaller chunks or use multiple inputs.
-
Template Errors: Check template syntax. The application provides detailed error messages and visual indicators.
-
Browser Compatibility: Ensure your browser supports WebAssembly.
-
Auto-completion Issues: If suggestions don't appear, ensure you're typing in the template editor and check the context.
-
Input Configuration: When using multiple inputs, ensure each has a unique name and valid data content.
- Use specific regular expressions in templates
- Avoid overly complex nested groups
- Process data in reasonable chunks or use multiple inputs
- Clear results between large processing runs
- Use group filtering in inputs to process only relevant data
- Take advantage of auto-completion for faster template writing
This is a standalone application. To contribute:
- Fork the repository
- Make your changes
- Test across different browsers
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This project uses the following open-source libraries:
- Pyodide: Mozilla Public License 2.0
- TTP: MIT License
- Monaco Editor: MIT License
- Built on the excellent Pyodide project
- Uses the powerful TTP library by Denis Mulyalin
- Code editing powered by Monaco Editor
- Inspired by the original TextFSM Nornir tool