Giter Club home page Giter Club logo

statamic-var's Introduction

var

var is a plugin for Statamic which allows theme authors to set and get variables easily inside a template.

Installing

  1. Download the zip file (or clone via git) and unzip it or clone the repo into /_add-ons/.
  2. Ensure the folder name is var (Github timestamps the download folder).
  3. Enjoy.

Usage

Set

Passing a value directly as a parameter.

{{ var:color is="green" }}
{{ var:weather is="cold" }}

Passing a value as content of a tag pair. Useful if you want to store long values, e.g. HTML snippets.

{{ var:color }}blue{{ /var:color }}
{{ var:weather }}sunny{{ /var:color }}

Setting both variable name and value as parameters. Useful when the variable name is dynamically generated.

{{ var:with name="color" is="blue" }}
{{ var:with name="weather" is="warm" }}

Get

Getting a variable value is just as easy.

{{ var:color }}
{{ var:with name="color" }}

Exists

You can check if a variable exists with {{ var:exists name="foo" }}.

{{ var:exists name="foo" }} // false

{{ var:foo is="bar" }}
{{ var:exists name="foo" }} // true

Extract

You can extract variables into the current context. This is useful if you need to apply modifiers to variables for example.

{{ var:color is="green" }}
{{ var:weather is="warm" }}

{{ var:extract }}
	{{ color }} // green
	{{ weather|upper }} // WARM
{{ /var:extract }}

Recipes

statamic-var's People

Contributors

michaelhue avatar curtisblackwell avatar jasonvarga avatar

Watchers

David Lokshin avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.