{ "info": { "author": "Artur Sousa", "author_email": "arturfelipe.sousa@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# css-class-names [![Build Status](https://travis-ci.org/arturfsousa/css-class-names.svg?branch=master)](https://travis-ci.org/arturfsousa/css-class-names)\n\nA python script for css class names conditional generation. Inspered by the node package [classnames](https://github.com/JedWatson/classnames).\n\n## Why?\n\nThe node `classnames` package has been helping me a lot with `React/JSX` and general javascript front-end development. I really missed something similar to use when working with `django` and `jinja2` templates, so, I decided to create this package.\n\n## Usage\n\nYou can add css class names by calling the function with arguments as:\n\n* Strings\n* Numbers: Floats or Integers (0 is allowed)\n* Sequences: Lists or Tuples\n* Dictionaries\n\n```python\nfrom css_class_names import class_names\n\nclass_names('header', 'is-visible') # 'header is-visible'\nclass_names(['is-visible', 'text-uppercase']) # 'is-visible text-uppercase'\nclass_names((100001000, 'clear')) # '100001000 clear'\n\nclass_names('header', { \n 'header--is-fixed': True, \n 'header--is-blue': False \n}) \n# 'header header--is-fixed'\n```\n\n### Conditional dicts\n\nDictionaries can be used to concat class names conditionally using expressions:\n\n```python\nfrom css_class_names import class_names\n\nerrors = ['Some error']\nclass_names('alert', { \n 'alert-danger': errors, \n 'alert-success': not errors,\n 'small': True\n}) \n# 'alert alert-danger'\n\nclass_names('client', { \n 'client-{}'.format(client.id): client, \n 'disable': not client.active()\n}) \n# 'client client-989'\n```\n\n### Excludes falsy values\n\nFalsy values (except 0) and not supported types will be ignored:\n\n```python\nfrom css_class_names import class_names\n\nclass_names([], '', False, {}, 0, object(), lambda x: x, None)\n# '0'\n```\n\n### Strip and flatten\n\nStrings are striped and sequences are recursively flattened:\n\n```python\nfrom css_class_names import class_names\n\nclass_names([' header ', [' green ', ' small ']])\n# 'header green small'\n```\n\n### Dedupe\n\nYou can dedupe names with the `dedupe` argument:\n\n```python\nfrom css_class_names import class_names\n\nclass_names('cart', 'is-open', 'is-logged', {'is-logged': True}, dedupe=True)\n# 'cart is-open is-logged'\n```\n\n### Prefix\n\nYou can add class name prefixes with the `prefix` argument. This is really usefull when you need a class namespace or using the [BEM](http://getbem.com/) methodology:\n\n```python\nfrom css_class_names import class_names\n\nclass_names('head', 'head--is-empty', {'head--is-large': True}, prefix='mysite-')\n# 'mysite-head mysite-head--is-empty mysite-head--is-large'\n```\n\n## Development\n\nAfter cloning the repository, create a virtualenv and use the `Makefile` commands to `setup` development requirements and run tests:\n\n```bash\nmake setup\nmake lint \nmake test \nmake watch # run tests when code changes\nmake coverage\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/arturfsousa/css-class-names", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "css-class-names", "package_url": "https://pypi.org/project/css-class-names/", "platform": "", "project_url": "https://pypi.org/project/css-class-names/", "project_urls": { "Homepage": "https://github.com/arturfsousa/css-class-names" }, "release_url": "https://pypi.org/project/css-class-names/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "A python script for css class names conditional generation", "version": "0.0.1" }, "last_serial": 4052861, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "c55f95ab4f2ca44df9f4393e2367a641", "sha256": "e14fdff5908b23509513e8a48d180954c42ea5a98238c0dfd8e68118e4564c90" }, "downloads": -1, "filename": "css_class_names-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c55f95ab4f2ca44df9f4393e2367a641", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 2883, "upload_time": "2018-07-12T03:09:12", "url": "https://files.pythonhosted.org/packages/2b/d0/1d15a71562459ec9ce5ff1eb1b7034872fc0e93df35b26a3f127d4ddba94/css_class_names-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "05294b5ce116afaaa7228c2ec5c2902b", "sha256": "4f2d9613c51f0cf5eb63e7aa962dfb3e084ddab91f2ac0b8163272976358caf8" }, "downloads": -1, "filename": "css-class-names-0.0.1.tar.gz", "has_sig": false, "md5_digest": "05294b5ce116afaaa7228c2ec5c2902b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2788, "upload_time": "2018-07-12T03:09:13", "url": "https://files.pythonhosted.org/packages/30/1a/61a2468df5d791797dc327b75022d9c028e2b16fa211d6cb65b950fe1ce2/css-class-names-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c55f95ab4f2ca44df9f4393e2367a641", "sha256": "e14fdff5908b23509513e8a48d180954c42ea5a98238c0dfd8e68118e4564c90" }, "downloads": -1, "filename": "css_class_names-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c55f95ab4f2ca44df9f4393e2367a641", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 2883, "upload_time": "2018-07-12T03:09:12", "url": "https://files.pythonhosted.org/packages/2b/d0/1d15a71562459ec9ce5ff1eb1b7034872fc0e93df35b26a3f127d4ddba94/css_class_names-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "05294b5ce116afaaa7228c2ec5c2902b", "sha256": "4f2d9613c51f0cf5eb63e7aa962dfb3e084ddab91f2ac0b8163272976358caf8" }, "downloads": -1, "filename": "css-class-names-0.0.1.tar.gz", "has_sig": false, "md5_digest": "05294b5ce116afaaa7228c2ec5c2902b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2788, "upload_time": "2018-07-12T03:09:13", "url": "https://files.pythonhosted.org/packages/30/1a/61a2468df5d791797dc327b75022d9c028e2b16fa211d6cb65b950fe1ce2/css-class-names-0.0.1.tar.gz" } ] }