Feature: Template Renderer Error Handling and Edge Cases Scenario Outline: Template renderer initialization failures for missing packages Given I try to initialize a TemplateRenderer with the "" engine When the required package "" is not installed Then a TemplateError should be raised with a message containing "" Examples: | engine | package | message | | jinja2 | jinja2 | Jinja2 is not installed. Install it with 'pip install jinja2'. | | mustache | pystache | Pystache is not installed. Install it with 'pip install pystache'. | Scenario: Template renderer initialization with unsupported engine Given I have an unsupported template engine type When I try to initialize a TemplateRenderer with this engine type Then a TemplateError should be raised with a message containing "Unsupported template engine" Scenario: Registering a template with an empty name Given a TemplateRenderer with the "simple" engine When I attempt to register a template with an empty name Then a TemplateError should be raised with a message containing "Template name cannot be empty" Scenario: Registering an invalid Jinja2 template Given a TemplateRenderer with the "jinja2" engine When I try to register a template with invalid Jinja2 syntax "Hello, {{ name" Then a TemplateError should be raised with a message containing "Failed to register Jinja2 template 'invalid'" Scenario: Rendering a simple template with missing format variables Given a TemplateRenderer with the "simple" engine And a template named "test" with content "Hello, {name}" When I try to render the "test" template with an empty context Then a TemplateError should be raised with a message containing "Missing template variable: name" Scenario: Rendering a simple string with missing format variables Given a TemplateRenderer with the "simple" engine When I try to render the string "Hello, {name}" with an empty context Then a TemplateError should be raised with a message containing "Missing template variable: name" Scenario: Rendering a simple template with a placeholder evaluating to None Given a TemplateRenderer with the "simple" engine And a template named "test" with content "Value: {{novalue}}" When I render the "test" template with context '{"novalue": null}' Then the result should be "Value: " Scenario: Rendering a simple template with an invalid expression Given a TemplateRenderer with the "simple" engine And a template named "test" with content "Value: {{ 1 +/ 2 }}" When I try to render the "test" template with any context Then a TemplateError should be raised with a message containing "Failed to render template 'test'" Scenario: Rendering a simple string with an invalid expression Given a TemplateRenderer with the "simple" engine When I try to render the string "Value: {{ 1 +/ 2 }}" with any context Then a TemplateError should be raised with a message containing "Failed to render template string" Scenario: Getting a non-existent template Given a TemplateRenderer with the "simple" engine When I try to get a template named "nonexistent" Then a TemplateError should be raised with a message containing "Template 'nonexistent' not found" Scenario: Rendering a non-existent template Given a TemplateRenderer with the "simple" engine When I try to render a template named "nonexistent" with any context Then a TemplateError should be raised with a message containing "Template 'nonexistent' not found" Scenario: Registration failure with Jinja2 due to bad engine object Given a TemplateRenderer with the "jinja2" engine And I have manually modified the engine to be invalid When I try to register a template named "test" with content "Hello" Then a TemplateError should be raised with a message containing "Jinja2 environment has no from_string method" Scenario: Rendering failure with Jinja2 due to bad template object Given a TemplateRenderer with the "jinja2" engine And I have manually registered a template named "bad_template" that is not a valid Jinja2 template object When I try to render the "bad_template" template with any context Then a TemplateError should be raised with a message containing "Jinja2 template has no render method" Scenario: String rendering failure with Jinja2 due to bad engine object Given a TemplateRenderer with the "jinja2" engine And I have manually modified the engine to be invalid When I try to render the string "Hello, {{name}}" with any context Then a TemplateError should be raised with a message containing "Jinja2 environment has no from_string method" Scenario: Rendering failure with Mustache due to bad engine object Given a TemplateRenderer with the "mustache" engine And I have manually modified the engine to be invalid And a template named "test" with content "Hello, {{name}}" When I try to render the "test" template with any context Then a TemplateError should be raised with a message containing "Mustache renderer has no render method" Scenario: String rendering failure with Mustache due to bad engine object Given a TemplateRenderer with the "mustache" engine And I have manually modified the engine to be invalid When I try to render the string "Hello, {{name}}" with any context Then a TemplateError should be raised with a message containing "Mustache renderer has no render method" Scenario: Rendering with an unsupported engine type Given a TemplateRenderer with the "simple" engine And I have manually set the engine type to an unsupported value And a template named "test" with content "Hello" When I try to render the "test" template with any context Then a TemplateError should be raised with a message containing "Unsupported template engine" Scenario: String rendering with an unsupported engine type Given a TemplateRenderer with the "simple" engine And I have manually set the engine type to an unsupported value When I try to render the string "Hello" with any context Then a TemplateError should be raised with a message containing "Unsupported template engine"