Giter Club home page Giter Club logo

armstrong.core.arm_layout's Introduction

armstrong.core.arm_layout

Provides layout related code for use in Armstrong and Django projects.

arm_layout provides you with tools to help streamline displaying content from within your application.

Usage

To load the template tags, add the following line (generally at the top of your template):

{% load layout_helpers %}

Once you have loaded the layout_helpers, you can use the render_model template tag to display a given model like this:

{% render_model some_model "full_page" %}

some_model is a variable in your template that is a model instance and the string "full_page" is the name of your "layout". render_model looks for a template named layout/<app_label>/<model>/<layout>.html to determine what to use to display your model instance.

render_model goes one step further, however. It is smart enough to walk through the inheritance of the model to determine if there are any other models that have the layout that can be used. For example, if some_model was an instance of armstrong.apps.articles.models.Article which inherits from armstrong.apps.content.models.Content, render_model looks for the following templates, in this order:

["layout/articles/article/full_page.html",
 "layout/content/content/full_page.html", ]

You have access to the entire template context inside the full_page.html template. You also have a new variable called object which represents the model instance that you provided to render_model. That variable is only available inside the layout template and temporarily overrides any context variable called object. Once render_model is finished, it restores the original context.

Installation & Configuration

You can install the latest release of armstrong.core.arm_layout using pip:

pip install armstrong.core.arm_layout

Make sure to add armstrong.core.arm_layout to your INSTALLED_APPS. You can add this however you like. This works as a copy-and-paste solution:

INSTALLED_APPS += ["armstrong.core.arm_layout", ]

Contributing

  • Create something awesome -- make the code better, add some functionality, whatever (this is the hardest part).
  • Fork it
  • Create a topic branch to house your changes
  • Get all of your commits in the new topic branch
  • Submit a pull request

State of Project

Armstrong is an open-source news platform that is freely available to any organization. It is the result of a collaboration between the Texas Tribune and Bay Citizen, and a grant from the John S. and James L. Knight Foundation.

To follow development, be sure to join the Google Group.

armstrong.core.arm_layouts is part of the Armstrong project. You're probably looking for that.

License

Copyright 2011-2012 Bay Citizen and Texas Tribune

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

armstrong.core.arm_layout's People

Contributors

niran avatar tswicegood avatar

Stargazers

 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.