Skip to content

Commit

Permalink
Docs for common and maps.
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-stitt committed Dec 7, 2017
1 parent b3253c6 commit 1e0d70e
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
37 changes: 37 additions & 0 deletions docs/interpolation/common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Common
======

env
---

.. js:function:: env(key)

:param string key: The environment key to get
:return: The value of the environment variable, or "" if it doesn't exist

Example
^^^^^^^

.. code-block:: guess
env("FOO") // foo
length
------

.. js:function:: length(object)

:param string/list/map object: The object to return the length of
:return: The length of the object.
If object is a string, it is the number of characters.
If object is a list, it is the number of items in the list.
If object is a map, it is the number of keys in the map.

Example
^^^^^^^

.. code-block:: guess
length("hello") // 5
length(["foo", "bar"]) // 2
length({"foo": "bar"}) // 1
65 changes: 65 additions & 0 deletions docs/interpolation/maps.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Maps
====

has
---

.. js:function:: has(map, key)

:param map map: The map to perform the lookup on
:param string key: The key to look for
:return: A bool as to whether or not the key exists

Example
^^^^^^^

.. code-block:: guess
has({"foo": "bar"}, "foo") // true
map
---

.. js:function:: map(key, value, ...)

:param string key: The key for the key/value pair
:param any value: The value for the key/value/pair
:return: A map object consisting of the provided key/value pairs

Example
^^^^^^^

.. code-block:: guess
map("foo", "bar") // {"foo": "bar"}
map("foo", list(1, 2, 3), "bar", list(3, 2, 1)) // {"foo": [1, 2, 3], "bar": [3, 2, 1]}
keys
----

.. js:function:: keys(map)

:param map map: The map to extract keys
:return: The list of keys from the map

Example
^^^^^^^

.. code-block:: guess
keys(map("foo", "bar")) // ["foo"]
merge
-----

.. js:function:: merge(map1, ...)

:param map map1: One or many maps to merge
:return: The result of the merge

Example
^^^^^^^

.. code-block:: guess
merge(map("foo", "bar"), map("foo", "bar2", "hello", "there")) // {"foo": "bar2", "hello": "there"}

0 comments on commit 1e0d70e

Please sign in to comment.