Answers.Body: <p>I'm not familiar with Jade so I can't speak to that, however I would suspect that even if Jade did allow Twig syntax it would be mostly redundant.</p>
  
  <p>Regarding variables. There are a number of ways to create variables in craft.</p>
  
  <ul>
  <li><a href="http://twig.sensiolabs.org/doc/tags/set.html" rel="nofollow">Twig Variables</a> - defined using <code>{% set variable = 'value' %}</code>, which can be printed using <code>{{ variable }}</code> or otherwise referenced by name. You can also assign a block of code to a variable using <code>{% set variable %}...{% endset %}</code>.</li>
  <li><a href="http://buildwithcraft.com/docs/globals" rel="nofollow">Globals</a> - global fields defined within the CP which can be accessed in your templates using <code>{{ globalSetHandle.fieldHandle }}</code>.</li>
  <li><a href="http://buildwithcraft.com/docs/config-settings#environmentVariables" rel="nofollow">Environment Variables</a> can also be defined in your config file (although these are generally reserved for variables that are unique to a particular environment, i.e. 'BaseUrl' ).</li>
  <li><a href="http://buildwithcraft.com/docs/plugins/variables" rel="nofollow">Plugin Template Variables</a> - defined in php in your plugin's variables files</li>
  </ul>
  
  <p>You might also want to look at Twigs <code>extends</code>, <code>include</code>, and <code>embed</code> methods.</p>
  
  <p>I'm not exactly sure what you mean by "custom function for each global variable". Twig has some methods and functions that allow you to manipulate data (see <a href="http://twig.sensiolabs.org/doc/functions/index.html" rel="nofollow">twig functions</a> and <a href="http://buildwithcraft.com/docs/templating/functions" rel="nofollow">craft functions</a>), as well as <code>macro</code> functionality for creating reusable code. Although if you are doing anything overly complicated it might be best to create a custom <a href="https://buildwithcraft.com/docs/plugins/introduction" rel="nofollow">plugin</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-21T22:40:20.260Z
Answers.Text: Thanks Douglas. Can you elaborate how to set up globals? I assumed it worked like low variables, but can't seem to understand how to do the same. After creating the global ( name & handle ) I am not exactly sure what to do next. Do i create a text field where I define the variable?
Answers.UserDisplayName: juju
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-21T23:23:53.313Z
Answers.Text: You first want to set up fields to hold your data (i.e. 'myTextField', 'myOtherTextField', etc.). Then create a new 'global set' under 'settings->globals->create new global set'. Then add the field(s) you created to the field layout tab of the global set. Then save. With at least one global set defined, you will get a new tab at the top of the control panel called 'globals'. Select that tab, select the new global set, and enter data into your field(s).
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-01-21T19:24:36.403Z
Answers.LastActivityDate: 2015-01-21T19:24:36.403Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I am getting myself confused with how to define variables in craft. I am thinking in expressionengine mode where I can define a custom global variable to be used later in my templates.  I see craft has what it calls "Globals" but i don't see where I can add a custom function for each global variable. Am I looking at this all wrong? </p>
  
  <p>Or is everything done directly on the template? I am developing using jade, which is then compiled into the final html template. So running into errors adding the twig templating language into my jade templates. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-21T16:19:38.757Z
Comments.Text: You can't use Craft without using Twig syntax in your templates. Were you able to use jade in your "expression engine mode"?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-21T18:35:51.870Z
Comments.Text: I feel like there is about a dozen questions in there, but I'm not sure what any of them are asking.  Can you try and clarify what you're attempting to do?
Comments.UserDisplayName: Brad Bell
Tags: <templating><variable><globals>
Title: Defining Variables
ThreadText: # Defining Variables
  
  (Asked by: username_0 on 2015-01-21)
  
  I am getting myself confused with how to define variables in craft. I am thinking in expressionengine mode where I can define a custom global variable to be used later in my templates. I see craft has what it calls "Globals" but i don't see where I can add a custom function for each global variable. Am I looking at this all wrong?
  
  Or is everything done directly on the template? I am developing using jade, which is then compiled into the final html template. So running into errors adding the twig templating language into my jade templates.
  
  **Tags:** templating, variable, globals
  
  > **Comments:**
  > **username_1**: You can't use Craft without using Twig syntax in your templates. Were you able to use jade in your "expression engine mode"?  
  > **username_2**: I feel like there is about a dozen questions in there, but I'm not sure what any of them are asking.  Can you try and clarify what you're attempting to do?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2015-01-21. Score: 3
  
  I'm not familiar with Jade so I can't speak to that, however I would suspect that even if Jade did allow Twig syntax it would be mostly redundant.
  
  Regarding variables. There are a number of ways to create variables in craft.
  
  * [Twig Variables](http://twig.sensiolabs.org/doc/tags/set.html) - defined using `{% set variable = 'value' %}`, which can be printed using `{{ variable }}` or otherwise referenced by name. You can also assign a block of code to a variable using `{% set variable %}...{% endset %}`.
  * [Globals](http://buildwithcraft.com/docs/globals) - global fields defined within the CP which can be accessed in your templates using `{{ globalSetHandle.fieldHandle }}`.
  * [Environment Variables](http://buildwithcraft.com/docs/config-settings#environmentVariables) can also be defined in your config file (although these are generally reserved for variables that are unique to a particular environment, i.e. 'BaseUrl' ).
  * [Plugin Template Variables](http://buildwithcraft.com/docs/plugins/variables) - defined in php in your plugin's variables files
  
  You might also want to look at Twigs `extends`, `include`, and `embed` methods.
  
  I'm not exactly sure what you mean by "custom function for each global variable". Twig has some methods and functions that allow you to manipulate data (see [twig functions](http://twig.sensiolabs.org/doc/functions/index.html) and [craft functions](http://buildwithcraft.com/docs/templating/functions)), as well as `macro` functionality for creating reusable code. Although if you are doing anything overly complicated it might be best to create a custom [plugin](https://buildwithcraft.com/docs/plugins/introduction).
  
  > **Comments:**
  > **username_0**: Thanks username_3. Can you elaborate how to set up globals? I assumed it worked like low variables, but can't seem to understand how to do the same. After creating the global ( name & handle ) I am not exactly sure what to do next. Do i create a text field where I define the variable?  
  > **username_3**: You first want to set up fields to hold your data (i.e. 'myTextField', 'myOtherTextField', etc.). Then create a new 'global set' under 'settings->globals->create new global set'. Then add the field(s) you created to the field layout tab of the global set. Then save. With at least one global set defined, you will get a new tab at the top of the control panel called 'globals'. Select that tab, select the new global set, and enter data into your field(s).  
  
  ---
  
  