render

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2025 License: MIT Imports: 9 Imported by: 0

README

dis-design-system-go

Proof of concept rendering library for Dissemination frontend go microservices. dis-design-system-go contains templates, localisations, model structs, css and javascript that are core to all dissemination frontend services.

Getting started

  • Run make help to see full list of make targets
Install dependencies

If you work across multiple Node.js projects there's a good chance they require different Node.js and npm versions.

It is recommended that you use nvm (Node Version Manager) to switch between versions easily:

  1. Install nvm:

    brew install nvm
    

    ⚠ Make sure to follow the instructions provided at the end of the install to configure up your shell profile.

  2. Install the node version specified in .nvmrc through nvm:

    nvm install
    
  • No further dependencies other than those defined in go.mod
Generate the CSS and JS
  • Build the CSS and JS, and start the local web server with

    make debug
    
  • Once built, you can find assets stored on the web server, default location is localhost:9002/dist/assets/

Contributing

See CONTRIBUTING for details.

License

Copyright © 2025, Office for National Statistics (https://www.ons.gov.uk)

Released under MIT license, see LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Render

type Render struct {
	PatternLibraryAssetsPath, SiteDomain string
	// contains filtered or unexported fields
}

func New

func New(client client.Renderer, assetsPath, siteDomain string) *Render

New returns a render struct and accepts any rendering client that satisfies the Renderer interface

func NewWithDefaultClient

func NewWithDefaultClient(assetFn func(name string) ([]byte, error), assetNameFn func() []string, assetsPath, siteDomain string) *Render

NewWithDefaultClient returns a render struct with a default rendering client provided (default: unrolled/render) When the siteDomain argument contains "localhost", then the rendering client will be instantiated in "development" mode. This means that templates are recompiled on request. Any updates made to your templates can then be viewed upon browser refresh, rather than having to restart the app.

func (*Render) BuildErrorPage

func (r *Render) BuildErrorPage(w io.Writer, pageModel model.Page, statusCode int)

BuildErrorPage resolves the rendering of a specific page with a given model and template name

func (*Render) BuildPage

func (r *Render) BuildPage(w io.Writer, pageModel interface{}, templateName string)

BuildPage resolves the rendering of a specific page with a given model and template name

func (*Render) NewBasePageModel

func (r *Render) NewBasePageModel() model.Page

NewBasePageModel wraps around the model package's NewPage function, but injects the assets path and site domain from the render struct. This is to negate the need for the caller to have to provide these values for every new page created in a frontend service

Directories

Path Synopsis
middleware

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL