func

func

[func.FunctionName(Params)]

Tags are case insensitive, but JavaScript is not. Thus FunctionName is case sensitive but the func. prefix is not.

Because func. is not an inline tag data is required. If no data is needed, specify blank data:

[Func.TestFunc():]

If not parameters are needed, the () is not required however specifying them helps to visually emphasize that it is a function call.

The func tag will look in the code behind file for the page and pass aTag: Tag as the only argument. The function must return a string.

Example:

MarkDown.ts

namespace Tests {
  export class MarkDown extends IntraWeb.Code {
    public TestFunc(aTag: IntraWeb.Tag) {
      return "Hello from code";
    }

    public Repeat(aTag: IntraWeb.Tag) {
      const xCount = Number(aTag.Params);
      return aTag.Data.repeat(xCount);
    }
  }
}

MarkDown.iwml

ACORN 1.0 IWML 1.0
Tests.MarkDown
  Root[]
    SimpleStack[Text]
      [Func.TestFunc:] and more
      [Func.TestFunc():] and more
      [Func.TestFunc] and more
      [Func.TestFunc()] and more
      [Func.Repeat(4):Pete]
      [Func.Repeat(4)]Pete
    ]
  ]
]

Output

Note that the third and fourth entries do not display “and more”. This is because it is the data of the tag, and our TestFunc ignores the data value, so in essence it “eats” it. The data is available in the Tag object should the function decide to use it.