{# filter_plugin_template.j2 #}
{%- set filter_name = plugin_name | default("sample_filter",true) -%}
{%- set author = author | default("Your Name") -%}
{%- set description = description | default("A custom filter plugin for Ansible.") -%}
{%- set license = license | default("GPL-3.0-or-later") -%}
# {{ filter_name }}.py - {{ description }}
# Author: {{ author }}
# License: {{ license }}

from __future__ import absolute_import, annotations, division, print_function


__metaclass__ = type  # pylint: disable=C0103

from typing import TYPE_CHECKING


if TYPE_CHECKING:
    from typing import Callable


DOCUMENTATION = """
    name: {{ filter_name }}
    author: {{ author }}
    version_added: "1.0.0"
    short_description: {{ description }}
    description:
      - This is a demo filter plugin designed to return Hello message.
    options:
      name:
        description: Value specified here is appended to the Hello message.
        type: str
"""

EXAMPLES = """
# {{ filter_name }} filter example
{% raw %}
- name: Display a hello message
  ansible.builtin.debug:
    msg: "{{ 'ansible-creator' {%- endraw %} | {{ filter_name }} }}"
"""


def _sample_filter(name: str) -> str:
    """Returns Hello message.

    Args:
        name: The name to greet.

    Returns:
        str: The greeting message.
    """
    return "Hello, " + name


class FilterModule:
    """filter plugin."""

    def filters(self) -> dict[str, Callable[[str], str]]:
        """Map filter plugin names to their functions.

        Returns:
            dict: The filter plugin functions.
        """
        return {"{{ filter_name }}": _sample_filter}
