Repeat template blocks with ease!
SameAs is a small Django application that provides you with an easy-to-use template tag to replicate a block.
For example you may want to repeat your title block somewhere else in your page.
{% load sameastags %}
...
<head>
<title>{% block title %}{{ object.title }}{% endblock %}</title>
</head>
<body>
<h1>{% sameas title %}</h1>
</body>
...
It's as simple as this.
But the real benefit of this feature is when used with template inheritance.
base.html:
...
{% load sameastags %}
...
<title>{% block title %}{% endblock %}</title>
<meta property="og:title" content="{% sameas title %}">
...
<h1>{% sameas title %}</h1>
...
inner.html
...
{% extends "base.html" %}
{% block title %}{{ object.title }}{% endblock %}
...
Tag library loading should occur before any blocks are declared.
It's good if you place {% load sameastags %}
somewhere at the top of
your page.
The application is currently not available on PyPI. To install it, you need to
- Clone this repository
- Add sameas package to PYTHONPATH
- Add 'sameas' to your INSTALLED_APPS
- Python 2 or 3
- Django (tested against 1.5, but I expect it to work with previous versions too)
If you're interested in the project and you contribute, please make sure:
- your changes don't break current tests
- you add appropriate tests for your features/bug fixes.
To run the tests simply use
$ ./manage.py test sameas
This project is licensed under LGPLv3. Read LICENSE for details.
I don't want to flood PyPI with something as simple as 20 lines of code. If the project turns out to be of valuable help, I'll reconsider.
django-sameas's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.