docs/en/docs/rules/tpl.md
tpl is an enhanced version of the file function, providing simple template engine functionality.
pattern tpl://value [filters...]
| Parameters | Description | Detailed Documentation |
|---|---|---|
| pattern | Expression to match request URLs | Match Pattern Documentation |
| value | Operation content, supports the following types: | |
| • Directory/File Path | ||
| • Remote URL | ||
| • Inline/Embedded/Values content | Operation Instruction Documentation | |
| filters | Optional filters, supports matching: | |
| • Request URL/Method/Header/Content | ||
| • Response Status Code/Header | Filter Documentation |
{key} or {{key}}key: A property in the request parameters/User/xxx/test.js{callback}({
ec: 0
});
https://www.example.com/test/tpl tpl:///User/xxx/test.js
# Supports remote URLs
# pattern tpl://https://example.com/template
https://www.example.com/test/tpl?callback=test Returns:test({
ec: 0
});
For other functions, refer to file