Skip to content

2.) Globals

Allen Royston edited this page Jul 30, 2018 · 1 revision

Global variables

Global variables (located in html/globals.json) generally don't need to be altered unless you plan on adding additional properties. If you do, however, their addition will be noticed on site refresh.

The file currently looks like this:

{
  "content": [
    {
      "title": "subject line",
      "key": "subjectline",
      "value": "Subject Line",
      "type": "input"
    },        
    {
      "title": "email width",
      "key": "m_width",
      "value": "600",
      "type": "inputpx"
    },
    {
      "title": "body color",
      "key": "g_bgcolor",
      "value": "#f2f2f2",
      "type": "inputcolor"
    },       
    {
      "title": "global black",
      "key": "g_black",
      "value": "#2c3e50",
      "type": "inputcolor"
    },    
    {
      "title": "global white",
      "key": "g_white",
      "value": "#ffffff",
      "type": "inputcolor"
    },        
    {
      "title": "global color 1",
      "key": "g_color1",
      "value": "#c0392b",
      "type": "inputcolor"
    },
    {
      "title": "global color 2",
      "key": "g_color2",
      "value": "#d35400",
      "type": "inputcolor"
    },
    {
      "title": "global color 3",
      "key": "g_color3",
      "value": "#f39c12",
      "type": "inputcolor"
    },
    {
      "title": "global color 4",
      "key": "g_color4",
      "value": "#8e44ad",
      "type": "inputcolor"
    },
    {
      "title": "global color 5",
      "key": "g_color5",
      "value": "#2980b9",
      "type": "inputcolor"
    },
    {
      "title": "global color 6",
      "key": "g_color6",
      "value": "#27ae60",
      "type": "inputcolor"
    }                          
  ]
}

Using a Global in a partial

In a template, you can easily apply a global by adding the key value into the partial. For example, if you want to use a globals simply add it into your html partial as such:

<tr>
  <td bgcolor="[g_color5]" >
    <h1 style='color: [g_black]' >[subjectline]</h1>
  </td>
</tr>

Setting a Global as a default value

{
  "name": "Example",
  "metadata": {
    "type": "prebuilt"
  },
  "content": [
    {
      "title": "text color",
      "key": "textcolor",
      "value": "[g_white]",
      "type": "inputcolor"
    },
    {
      "title": "background color",
      "key": "bg_color",
      "value": "[g_color1]",
      "type": "inputcolor"
    }
  ]
}

Clone this wiki locally