Coder Social home page Coder Social logo

govuk_template's Introduction

GovukTemplate

This provides a template containing the GOV.UK header and footer, and associated assets.

This is versioned following Semantic Versioning.

Requirements

The Ruby language (1.9.3+), the build tool Rake & the dependancy management tool Bundler

Packaging

At present this generates 4 output formats:

  1. a gem containing a Rails engine
  2. a tarball containing Play Framework templates
  3. a folder containing Mustache templates
  4. a tarball

Gem version

This is available on rubygems.org. To use it, add this line to your application's Gemfile:

gem 'govuk_template'

And then execute:

$ bundle

You can then use the govuk_template layout in your app. If you need to extend the layout you can use nested layouts.

Play version

To generate the tarball of Play Framework templates run bundle exec rake build:play. This will produce a tarball in the pkg directory.

Mustache version

To generate the folder of Mustache templates run bundle exec rake build:mustache. This will produce a folder in the pkg directory.

Tarball version

To generate the tarball, run the bundle exec rake build:tar. This will produce a tarball in the pkg directory.

Publishing

Accepted contributions (pull requests merged into master) will run builds for the Gem, Play and Mustache versions. These will then update the following:

Development

The source files are in the /source directory. The compile rake task builds the /app contents from these sources. This process involves the following:

  • compiling all stylesheets referenced in /manifests.yml to plain CSS (actually css.erb, so the Rails asset pipeline can work in the gem).
  • combining all JavaScript files referenced in /manifests.yml (using Sprockets)
  • copying the images across (including any needed images from the toolkit)

This resulting app directory is included in the gem and hooked in as a Rails engine

Extra details for the tarball build

The tarball build process takes the compiled template and assets from the /app directory, and performs some extra processing:

  • it compiles the *.css.erb files to plain CSS, replacing all calls to asset_path with the relative path to the asset. For this reason, all assets referenced in the stylesheets must be stored relative to the stylesheet.
  • it compiles the erb layout to plain html.
    • All asset_path calls are replaced by the the path to the assets, assuming the assets folder is served from /assets
    • Any content_for? calls are assumed to return false
    • yields in the template are removed except for the main layout one which is replaced with an HTML comment.

See the TemplateProcessor class for details of this implementation.

Usage

Propositional title and navigation

You can get a propositional title and navigation by setting the content for header_class to with-proposition and proposition_header in the form:

<div class="header-proposition">
  <div class="content">
    <a href="#proposition-links" class="js-header-toggle menu">Menu</a>
    <nav id="proposition-menu">
      <a href="/" id="proposition-name">Service Name</a>
      <ul id="proposition-links">
        <li><a href="url-to-page-1" class="active">Navigation item #1</a></li>
        <li><a href="url-to-page-2">Navigation item #2</a></li>
      </ul>
    </nav>
  </div>
</div>

This will then create a navigation block which is shown on desktop sized devices but collapsed down on smaller screens.

Contributing

Please follow the contribution guidelines.

govuk_template's People

Contributors

alexmuller avatar alext avatar bradwright avatar cjcheshire avatar edds avatar jabley avatar jcbashdown avatar jordanhatch avatar kushalp avatar markhurrell avatar michaeldfallen avatar mnowster avatar norm avatar petems avatar tombye avatar

Watchers

 avatar  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.