PM::Parsed¶
The result object returned by PM.parse. A Struct with two fields: metadata and content.
Source¶
lib/pm/parsed.rb
Structure¶
Fields¶
| Field | Type | Description |
|---|---|---|
metadata |
PM::Metadata | Parsed YAML front-matter |
content |
String | Markdown content after metadata extraction and shell expansion |
Methods¶
[](key) → Object¶
Bracket accessor that delegates to metadata:
parsed = PM.parse("---\ntitle: Hello\n---\nContent")
parsed[:title] #=> "Hello"
parsed['title'] #=> "Hello"
to_s(values = {}) → String¶
Render the prompt content with ERB template evaluation.
Parameters:
| Name | Type | Description |
|---|---|---|
values |
Hash | Parameter values to merge with defaults |
Returns: Rendered prompt as String.
Raises: ArgumentError if required parameters (those with nil defaults) are not provided.
Behavior:
- Merges provided values with parameter defaults from metadata
- Validates all required parameters are present
- If
erb: true, evaluates ERB with parameters and registered directives - If
erb: false, returns content as-is - Populates
metadata.includeswith the include tree
parsed = PM.parse('review.md')
# With required params
result = parsed.to_s('code' => File.read('app.rb'))
# Override defaults
result = parsed.to_s('code' => source, 'language' => 'python')
# Symbol keys work
result = parsed.to_s(code: source)
render_with(values, included, depth) → String¶
Internal method used by to_s and the include directive. Handles the ERB rendering pipeline with include tracking.
Parameters:
| Name | Type | Description |
|---|---|---|
values |
Hash | Merged parameter values |
included |
Set | File paths already in the include chain |
depth |
Integer | Current include nesting depth |
This method is not typically called directly.