Fragmenta view

包 view 为 golang 视图提供了模板注册、渲染和帮助功能。「Package view provides template registration, rendering, and helper functions for golang views」

  • Owner: fragmenta/view
  • Platform: Linux, Mac, Windows
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Fragmenta view

包 view 为 golang 视图提供了模板注册、渲染和帮助功能。

用法

在应用程序启动时加载模板

err := view.LoadTemplates()
    if err != nil {
        server.Fatalf("Error reading templates %s", err)
    }

渲染一个模板

 // Set up the view
    view := view.New(context)
    // Add a key to the view
    view.AddKey("page", page)
    // Optionally set template, layout or other attributes
    view.Template("src/pages/views/home.html.got")
    // Render the view
    return view.Render()

公共子包

  • helpers -- 处理文件的工具


Overview

Name With Ownerfragmenta/view
Primary LanguageGo
Program languageGo (Language Count: 1)
PlatformLinux, Mac, Windows
License:MIT License
Release Count18
Last Release Namev1.6.2 (Posted on )
First Release Namev1 (Posted on )
Created At2015-07-25 15:14:08
Pushed At2020-11-23 14:08:20
Last Commit At2020-11-17 23:04:45
Stargazers Count11
Watchers Count3
Fork Count6
Commits Count53
Has Issues Enabled
Issues Count3
Issue Open Count0
Pull Requests Count0
Pull Requests Open Count0
Pull Requests Close Count1
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

view

Package view provides template registration, rendering, and helper functions for golang views

Usage

Load templates on app startup:

	err := view.LoadTemplates()
	if err != nil {
		server.Fatalf("Error reading templates %s", err)
	}

Render a template

    // Set up the view
	view := view.New(context)
    // Add a key to the view
    view.AddKey("page", page)
    // Optionally set template, layout or other attributes
    view.Template("src/pages/views/home.html.got")
    // Render the view
    return view.Render()

Public subpackages:

  • helpers - utilities for handling files
To the top