tpl
tpl is an enhanced version of the file function, providing simple template engine functionality.
Rule Syntax
txt
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 |
Template Rules
- Value format:
{key}or key: A property in the request parameters
Mock JSONP
- Local File
/User/xxx/test.js
js
{callback}({
ec: 0
});- Rule Configuration
txt
https://www.example.com/test/tpl tpl:///User/xxx/test.js
# Supports remote URLs
# pattern tpl://https://example.com/template- Request
https://www.example.com/test/tpl?callback=testReturns:
txt
test({
ec: 0
});For other functions, refer to file