fn: $
[contents]

Contents

Syntax

The syntax for $ calls is:

f++:  
$[string]

n++:  
$[string]

Description

The $ function is used for printing variables, it takes a single string as an input parameter, which should be a variable name, and prints the value of the variable.

Options

The following options are available for $ calls:

option description
\n add \n instead of newlines
!round do not round floating point values
option description

f++ example

Example of $ being used with f++:

int a=0

# following three lines are essentially the same
console("a: ", a)
console("a: ", $[a])
console("a: $[a]")

n++ example

Example of $ being used with n++:

@int a=0

@# following three lines are essentially the same
@console("a: ", a)
@console("a: ", $[a])
@console("a: $[a]")

Hard-coded variables

A number of hard-coded variables are available with both f++ and n++ which are outlined in the following sections.

Injecting file information

The following information about the output file being built can be injected:

type syntax
name $[name]
title $[title]
output file path $[output-path]
output extension $[output-ext]
content file path $[content-path]
content extension $[content-ext]
script extension $[script-ext]
template path $[template-path]
type syntax

For example in a file template/head.content you may want something along the lines of:

<title>sitename - $[title]</title>

Injecting pagination information

The following information about pagination for the output file being built can be injected:

type syntax
number of items to add per page $[paginate.no_items_per_page]
current number of pages $[paginate.no_pages]
output file path $[paginate.page]
current page number $[paginate.page_no]
code injected between items $[paginate.separator]
type syntax

Injecting project information

The following information about the project Nift is managing can be injected:

type syntax
content directory $[content-dir]
output directory $[output-dir]
default content extension $[default-content-ext]
default output extension $[default-output-ext]
default script extension $[default-script-ext]
default template $[default-template]
type syntax

Injecting operating system information

The following information about the operating system Nift is run from can be injected:

type syntax
build operating system $[build-OS]
call operating system $[current-OS]
type syntax

Injecting date, time and timezone information

The following information about dates and times can be injected:

type syntax
date of build $[build-date]
time of build $[build-time]
timezone of build $[build-timezone]
UTC date of build $[build-UTC-date]
UTC time of build $[build-UTC-time]
year of build $[build-YY]
full year of build $[build-YYYY]
date of call $[current-date]
time of call $[current-time]
timezone of call $[current-timezone]
$[timezone]
UTC date of call $[current-UTC-date]
UTC time of call $[current-UTC-time]
year of call $[current-YY]
full year of call $[current-YYYY]
date of loading $[load-date]
time of loading $[load-time]
timezone of loading $[load-timezone]
UTC date of loading $[load-UTC-date]
UTC time of loading $[load-UTC-time]
year of loading $[load-YY]
full year of loading $[load-YYYY]
type syntax

Sponsors