Coder Social home page Coder Social logo

jayvdb / django-classy-tags Goto Github PK

View Code? Open in Web Editor NEW

This project forked from django-cms/django-classy-tags

0.0 1.0 0.0 267 KB

Class based template tags for django

Home Page: http://django-classy-tags.rtfd.org

License: Other

Python 96.28% HTML 3.72%

django-classy-tags's Introduction

Django Classy Tags

pypi build coverage

The goal of this project is to create a new way of writing Django template tags which is fully compatible with the current Django templating infrastructure. This new way should be easy, clean and require as little boilerplate code as possible while still staying as powerful as possible. Some features:

  • Class based template tags.
  • Template tag argument parser.
  • Declarative way to define arguments.
  • Supports (theoretically infinite) parse-until blocks.
  • Extensible!

Note

This project is considered 3rd party (no supervision by the django CMS Association). Join us on Slack for more information.

Contribute to this project and win rewards

Because this is a an open-source project, we welcome everyone to get involved in the project and receive a reward for their contribution. Become part of a fantastic community and help us make django CMS the best CMS in the world.

We'll be delighted to receive your feedback in the form of issues and pull requests. Before submitting your pull request, please review our contribution guidelines.

We're grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.

Documentation

See REQUIREMENTS in the setup.py file for additional dependencies:

python django

Please refer to the documentation in the docs/ directory for more information or visit our online documentation.

Example

This is how a tag looks like using django-classy-tags:

from classytags.core import Options
from classytags.helpers import AsTag
from classytags.arguments import Argument
from django import template

register = template.Library()

class Hello(AsTag):
    options = Options(
        Argument('name', required=False, default='world'),
        'as',
        Argument('varname', required=False, resolve=False)
    )

    def get_value(self, context, name):
        return 'hello %s' % name

register.tag(Hello)

That's your standard hello world example. Which can be used like this:

  • {% hello %}: Outputs hello world
  • {% hello "classytags" %}: Outputs hello classytags
  • {% hello as myvar %}: Outputs nothing but stores hello world into the template variable myvar.
  • {% hello "my friend" as othervar %}: Outputs nothing but stores hello my friend into the template variable othervar.

Running Tests

You can run tests by executing:

virtualenv env
source env/bin/activate
pip install -r tests/requirements.txt
python setup.py test

django-classy-tags's People

Contributors

ojii avatar finalangel avatar yakky avatar timgraham avatar yannik-ammann avatar kiahosseini avatar fladi avatar nicolairidani avatar brente avatar anukaal avatar bashu avatar vad avatar jimux avatar mariajgrimaldi avatar narenderrajub avatar thomasgoirand avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.