Giter Club home page Giter Club logo

ministryofjustice.springboot-mustach-govukstyle's Introduction

Spring Boot Mustache Govuk Assets Prototype

Overview Objective of this exercise is to create a prototype to demonstrate how to produce a working spring boot based MVC application utilising the mustache template to do server side html generation utilizing govuk-template, govuk-element-sass, govuk_frontend_toolkit.

Simple Steps to get started

  • Clone this repository
  • Run the application as one would do with any spring boot application
  • Access the local host on port 8080 (if you have not changed any defaults)
  • You can build your application just by adding your code on top of this and push it into your own git repository.

you can view an application with header, menu links, footer, and a message with an icon attached to it.

Making of this prototype and fine points to be noted.

Gradle Notes

Please take a note of these in the build.gradle file
    compile('org.springframework.boot:spring-boot-starter-mustache')
    compile('org.springframework.boot:spring-boot-starter-web')

Compile scss files during the boot run
    gulp_build.dependsOn 'installGulp'
    gulp_build.dependsOn 'npmInstall'

    bootRun.dependsOn gulp_build

    apply plugin: "com.moowork.gulp"

    classpath("com.moowork.gradle:gradle-gulp-plugin:0.10")

application.yml notes

spring:
  mustache:
    enabled: true
    prefix: classpath:/templates/
    check-template-location: true
    suffix: .html

Mustache Notes

Several fragment files are created and stored under /resources/templates/fragments
index.html shows how these fragments are used.

npm (Node Package Manager Notes)

Install nodejs (there by install npm automatically)
run npm init at the directory which needs to be the root of the UI project. This will produce the package.json

Install mandatory npm packages

npm i --save gulp
npm i --save gulp-sass
npm i --save gulp-sourcemaps
npm i --save gulp-clean
npm i --save require-dir
npm i --save run-sequence

npm i --save govuk_template_mustache
npm i --save govuk-elements-sass
npm i --save govuk_frontend_toolkit

Gulp Notes

Gulp is used as the tool to manage the gov-uk scss files. Please see the gulp.js and all the gulp files
under ./gulp folder

Gulp does the following
- Fetches the govuk_template_mustache, govuk-elements-sass and govuk_frontend_toolkit from node_modules and moves
the configured artifacts to src/resources/static/govuk_modules.

- Compiles all the scss files from govuk-elements-sass and govuk_frontend_toolkit and produces a global.css file
under src/resources/static/css/global.css

global.scss

 This is an important file where we plugin the entire gov-uk style elements. Along with this when gulp build is run
 a global.css file gets produced at /resources/static/css/global.css which contains compiled css elements from
 govuk-elements-sass and govuk_frontend_toolkit.

 $path: "/govuk_modules/govuk_frontend_toolkit/images/" - relative location of various images used by
 govuk-template-saas and govuk_frontend_toolkit.

govuk-template.css

This file can be found under src/resources/static/govuk_template/assets/stylesheets. This is needed for the header
and footer construction in the html.

head.html

Please take a note of how two crucial css files are included in here

<link rel="stylesheet" media="screen" href="/css/global.css"/>
<link rel="stylesheet" media="screen" href="{{{ assetPath }}}stylesheets/govuk-template.css?0.24.0"/>

{{{assetPath}}} is defined in application.yml and injected through the model in the MustacheDemoController.java

ministryofjustice.springboot-mustach-govukstyle's People

Contributors

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