Toggle Menu
Prev Up Next

# `langchain_core.utils.mustache`.tokenize

langchain_core.utils.mustache.tokenize(template: str, def_ldel: str = '{{', def_rdel: str = '}}') → Iterator[Tuple[str, str]]

  Tokenize a mustache template.

  Tokenizes a mustache template in a generator fashion, using file-like objects. It also accepts a string containing the template.

  Arguments:

  template – a file-like object, or a string of a mustache template

  def_ldel – The default left delimiter

    (“{{” by default, as in spec compliant mustache)

  def_rdel – The default right delimiter

    (“}}” by default, as in spec compliant mustache)

  Returns:

  A generator of mustache tags in the form of a tuple

  – (tag_type, tag_key)

  Where tag_type is one of:

    - literal

    - section

    - inverted section

    - end

    - partial

    - no escape

  And tag_key is either the key or in the case of a literal tag, the literal itself.

  Parameters

    - template (str) –

    - def_ldel (str) –

    - def_rdel (str) –

  Return type

    Iterator[Tuple[str, str]]