fett


Namefett JSON
Version 0.4.0 PyPI version JSON
download
home_page
SummaryA fast indentation-preserving template engine.
upload_time2022-10-31 21:02:38
maintainer
docs_urlNone
authorHeli Aldridge
requires_python>=3.7,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. |travis| image:: https://travis-ci.org/i80and/fett.svg?branch=master
            :target: https://travis-ci.org/i80and/fett

=============
Fett |travis|
=============

Overview
--------

Example
-------

.. code-block:: python

   import fett

   fett.Template('''{{ for customer in customers }}
   {{ if i even }}
   Even: {{ customer.name }}
   {{ else }}
   Odd: {{ customer.name }}
   {{ end }}
   {{ else }}
   No customers :(
   {{ end }}''').render({'customers': [
       {'name': 'Bob'},
       {'name': 'Elvis'},
       {'name': 'Judy'}
   ]})

Syntax
------

==========================================   ===========
Tag Format                                   Description
==========================================   ===========
``{{ <expression> }}``                       Substitutions_
``{{ `foo` <expression> }}``                 Substitutions_
``{{ format <name> }}``                      Metaformatting_
``{{ if <expression> }}``                    Conditionals_
``{{ for <name> in <expression> }}``         Loops_
``{{ else }}``
``{{ end }}``                                Block termination
``{{ # <comment> }}``                        Comments_
==========================================   ===========

Spaces between tag opening/closing delimiters are optional.

Expressions
~~~~~~~~~~~

An **expression** is given for Substitutions_, Conditionals_, and Loops_.

Expressions take the following form:

    <name>[.<subfield>...] [<filter> [<filter2>...]]

Instead of specifying a field path, you can start an expression using
a string literal:

    `<literal>` [<filter> [<filter2>...]]

You can use **filters** to modify a single value in simple ways. For example,
the loop iteration counter ``i`` counts from ``0``, but users often wish to
count from ``1``. You can obtain a count-from-1 value with the expression
``i inc``.

The full list of filters:

===========  ======
Filter Name  Effect
===========  ======
car          Returns the first element of a list.
cdr          Returns all but the first element of a list.
dec          Decrements a value representable as an integer by one.
even         Returns true iff its input is representable as an even integer.
escape       Encodes `&`, `<`, `>`, `"`, and `'` characters with HTML entities.
inc          Increments a value representable as an integer by one.
len          Returns the length of a list.
not          Returns the inverse of a boolean.
odd          Returns true iff its input is representable as an odd integer.
negative     Returns true iff its input is representable as an integer < 0.
positive     Returns true iff its input is representable as an integer > 0.
split        Splits a value into a list by whitespace.
strip        Returns the input string with surrounding whitespace removed.
striptags    Remove HTML tags from a value.
timesNegOne  Returns int(input) * -1
zero         Returns true iff the input is zero
===========  ======

===========  ======
Filter Name  Effect
===========  ======
upperCase    Returns a Unicode-aware uppercase version of the input.
lowerCase    Returns a Unicode-aware lowercase version of the input.
===========  ======

=====================  ======
Filter Name            Effect
=====================  ======
add(n)                 Increments a value representable as an integer by `n`.
minus(n)               Decrements a value representable as an integer by `n`.
equal(value)           Returns true iff a value equals the given value.
lessThan(n)            Returns true iff n < the given value.
lessThanOrEqual(n)     Returns true iff n <= the given value.
greaterThan(n)         Returns true iff n > the given value.
greaterThanOrEqual(n)  Returns true iff n >= the given value.
=====================  ======

Substitutions
~~~~~~~~~~~~~

Metaformatting
~~~~~~~~~~~~~~

Conditionals
~~~~~~~~~~~~

Loops
~~~~~

Comments
~~~~~~~~

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "fett",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Heli Aldridge",
    "author_email": "heli@heli.pet",
    "download_url": "https://files.pythonhosted.org/packages/13/c3/62d07518d5f12673b6894211f4320046987e7a2d5664a73337d521957a04/fett-0.4.0.tar.gz",
    "platform": null,
    "description": ".. |travis| image:: https://travis-ci.org/i80and/fett.svg?branch=master\n            :target: https://travis-ci.org/i80and/fett\n\n=============\nFett |travis|\n=============\n\nOverview\n--------\n\nExample\n-------\n\n.. code-block:: python\n\n   import fett\n\n   fett.Template('''{{ for customer in customers }}\n   {{ if i even }}\n   Even: {{ customer.name }}\n   {{ else }}\n   Odd: {{ customer.name }}\n   {{ end }}\n   {{ else }}\n   No customers :(\n   {{ end }}''').render({'customers': [\n       {'name': 'Bob'},\n       {'name': 'Elvis'},\n       {'name': 'Judy'}\n   ]})\n\nSyntax\n------\n\n==========================================   ===========\nTag Format                                   Description\n==========================================   ===========\n``{{ <expression> }}``                       Substitutions_\n``{{ `foo` <expression> }}``                 Substitutions_\n``{{ format <name> }}``                      Metaformatting_\n``{{ if <expression> }}``                    Conditionals_\n``{{ for <name> in <expression> }}``         Loops_\n``{{ else }}``\n``{{ end }}``                                Block termination\n``{{ # <comment> }}``                        Comments_\n==========================================   ===========\n\nSpaces between tag opening/closing delimiters are optional.\n\nExpressions\n~~~~~~~~~~~\n\nAn **expression** is given for Substitutions_, Conditionals_, and Loops_.\n\nExpressions take the following form:\n\n    <name>[.<subfield>...] [<filter> [<filter2>...]]\n\nInstead of specifying a field path, you can start an expression using\na string literal:\n\n    `<literal>` [<filter> [<filter2>...]]\n\nYou can use **filters** to modify a single value in simple ways. For example,\nthe loop iteration counter ``i`` counts from ``0``, but users often wish to\ncount from ``1``. You can obtain a count-from-1 value with the expression\n``i inc``.\n\nThe full list of filters:\n\n===========  ======\nFilter Name  Effect\n===========  ======\ncar          Returns the first element of a list.\ncdr          Returns all but the first element of a list.\ndec          Decrements a value representable as an integer by one.\neven         Returns true iff its input is representable as an even integer.\nescape       Encodes `&`, `<`, `>`, `\"`, and `'` characters with HTML entities.\ninc          Increments a value representable as an integer by one.\nlen          Returns the length of a list.\nnot          Returns the inverse of a boolean.\nodd          Returns true iff its input is representable as an odd integer.\nnegative     Returns true iff its input is representable as an integer < 0.\npositive     Returns true iff its input is representable as an integer > 0.\nsplit        Splits a value into a list by whitespace.\nstrip        Returns the input string with surrounding whitespace removed.\nstriptags    Remove HTML tags from a value.\ntimesNegOne  Returns int(input) * -1\nzero         Returns true iff the input is zero\n===========  ======\n\n===========  ======\nFilter Name  Effect\n===========  ======\nupperCase    Returns a Unicode-aware uppercase version of the input.\nlowerCase    Returns a Unicode-aware lowercase version of the input.\n===========  ======\n\n=====================  ======\nFilter Name            Effect\n=====================  ======\nadd(n)                 Increments a value representable as an integer by `n`.\nminus(n)               Decrements a value representable as an integer by `n`.\nequal(value)           Returns true iff a value equals the given value.\nlessThan(n)            Returns true iff n < the given value.\nlessThanOrEqual(n)     Returns true iff n <= the given value.\ngreaterThan(n)         Returns true iff n > the given value.\ngreaterThanOrEqual(n)  Returns true iff n >= the given value.\n=====================  ======\n\nSubstitutions\n~~~~~~~~~~~~~\n\nMetaformatting\n~~~~~~~~~~~~~~\n\nConditionals\n~~~~~~~~~~~~\n\nLoops\n~~~~~\n\nComments\n~~~~~~~~\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A fast indentation-preserving template engine.",
    "version": "0.4.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "2af79fca32638ea87c78f3c61def095e",
                "sha256": "01b43baf8c1b2520f52bc1f8e49cd0a08e9290292c8be5acc1c54bdc530e75cf"
            },
            "downloads": -1,
            "filename": "fett-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2af79fca32638ea87c78f3c61def095e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 6815,
            "upload_time": "2022-10-31T21:02:36",
            "upload_time_iso_8601": "2022-10-31T21:02:36.358803Z",
            "url": "https://files.pythonhosted.org/packages/46/e6/9c2150926e5aea200ac862fb7b7d9f14627c8354e667cd82aa15e2fd4343/fett-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "771ba7be023267a3a01d811d65c4c117",
                "sha256": "56912ad93cf537a450b4fb15ee97aedd97acf81a14e48375c523fffdeb182986"
            },
            "downloads": -1,
            "filename": "fett-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "771ba7be023267a3a01d811d65c4c117",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 6853,
            "upload_time": "2022-10-31T21:02:38",
            "upload_time_iso_8601": "2022-10-31T21:02:38.004769Z",
            "url": "https://files.pythonhosted.org/packages/13/c3/62d07518d5f12673b6894211f4320046987e7a2d5664a73337d521957a04/fett-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-10-31 21:02:38",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "fett"
}
        
Elapsed time: 0.01679s