Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9118811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:14:38+00:00 2026-06-17T05:14:38+00:00

In this example I have a main.html template <!DOCTYPE html> <html> <head> <title>Backend</title> <style>

  • 0

In this example I have a main.html template

<!DOCTYPE html>
<html>
<head>
  <title>Backend</title>
  <style>
    html, body {height:100%}
  </style>
</head>
<body>
  <table border="1" width="100%" height="100%">
    <tr>
      <td colspan="2" class="td-header">
        <h1>Google GO</h1>
      </td>
    </tr>
    <tr>
      <td class="td-right-content">
       {{<parsed template from children>}}
      </td>
    </tr>
    <tr>
      <td colspan="2" class="td-header">
        <h1>Footer</h1>
      </td>
    </tr>
  </table>
</body>
</html>

The child part would fill the

{{}}

With

<table>   
  <tr>
    <th>
      Name
    </th>
    <th>
      Description
    </th>
    <th>
    </th>
  </tr>
  {{range .}}
    <tr>
      <td>
        {{.Name}}
      </td>
      <td>
        {{.Description}}
      </td>
      <td>
        <a href="/admin/forms/edit/?key={{.Key.Encode}}">Edit</a>
      </td>
    </tr>
  {{end}}
</table>

After it has been parsed in the code of child part.
I am doing this to eliminate redundant html and css and to manage the design easily.
Thanks all!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:14:40+00:00Added an answer on June 17, 2026 at 5:14 am

    A Template object contains a top-level template (here: the parent template) which may reference other templates associated in the same object. Templates have a name used for referencement.

    It can be tricky, because when you use the ParseFiles function to create a new object, each template is named using the base name of the file (and it seems to be impossible to change that name). If you have multiple possible children files for a given main, it can be impractical because you usually don’t want to give them the same name.

    The solution it to manually read the file to a string and then add it to an explicitly named template (a little bit cumbersome IMO, but you can live with it).

    main_temp,_ := template.ParseFiles("main.html")
    
    cont_s,_ := ioutil.ReadFile("content1.html")
    
    // add a new associated template to main 
    cont_temp,_ := main_temp.New("content").Parse(string(cont_s))
    
    g := Content{"Hi"}
    main_temp.Execute(os.Stdout, &g)
    

    (I skipped all the error handling for the example)

    Then you can use the {{template}} directive in your parent page:

    {{template "content" .}}
    

    (or any pipeline instead of . which is referring to the whole object given to main_temp)

    See text/template doc for more details

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example.go, I have package main import html/template import net/http func handler(w http.ResponseWriter, r
I have page main.html in it i have this code in the body tag:
In this example we have 3 related tables on a SQLite database: CREATE TABLE
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
I have this example FactoryGirl.define do @site = FactoryGirl.create(:my_site) factory :user do email {
I have this example: public class Inheritance { public static class Animal { public
jquery.ui.position is not taking the margin values when positioning items? I have this example,
I have tried this example http://www.bennadel.com/blog/1056-ColdFusion-CFPOP-My-First-Look.htm , but it retrieve emails from POP server.
I have looked at this example using php and GD to piecewise-render a spiral
I have for example this string: iCanSeeBluePeople and I need it to separate it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.