When using the Common Includes pattern you may come across duplicated content that varies with only one or two values. This can make using includes difficult but when combined with variables, includes become even more powerful. You can parameterize included pages by declaring variables in the test page and referencing them in the included page.

First we'll include a parameterized include page without defining any variables.

Included page: SampleParameterizedPage (edit)

This page requires that 3 variables be defined before it is included.
  • NUMERATOR
  • DENOMINATOR
  • QUOTIENT

eg.Division
numerator denominator quotient?
undefined variable: NUMERATOR undefined variable: DENOMINATOR undefined variable: QUOTIENT

Now we define the required variables.
variable defined: NUMERATOR=100
variable defined: DENOMINATOR=10
variable defined: QUOTIENT=10

Included page: SampleParameterizedPage (edit)

This page requires that 3 variables be defined before it is included.
  • NUMERATOR
  • DENOMINATOR
  • QUOTIENT

eg.Division
numerator denominator quotient?
100 10 10

We can redefine the variables and use the parameterized include again.
variable defined: NUMERATOR=555
variable defined: DENOMINATOR=5
variable defined: QUOTIENT=111

Included page: SampleParameterizedPage (edit)

This page requires that 3 variables be defined before it is included.
  • NUMERATOR
  • DENOMINATOR
  • QUOTIENT

eg.Division
numerator denominator quotient?
555 5 111