Interactive demo
Use this page to test FuncyStr features dynamically. For this demo, the following functions are included:
Available functions:
{{PLURAL|singular|plural}}: Choose a version for singular and plural{{name}}: Display the value of the chosen name given inparams{{pronoun|he|she|they}}: Choose the correct version of the text for the given pronoun value inparams{{capitalize|text}}: Capitalize the given text{{abbr|term|desc}}: Create a<abbr>tag with the term and description.{{featuredwiki|year|month|day}}: Outputs English Wikipedia's featured article for the given date.
Instantiation code example
This code should only serve as an example for this demo purposes only. Before using this in your app, make sure there's proper validation of inputs, especially if the code runs on the server.
js
const fstr = new FuncyStr({
NAME: (params) => params.name,
PRONOUN: (params, he, she, they) => params.pronoun === 'he' ? he : params.pronoun === 'she' ? she : they,
CAPITALIZE: (params, text) => text.charAt(0).toUpperCase() + text.slice(1),
ABBR: (params, term, desc) => `<abbr title="${desc}">${term}</abbr>`,
FEATUREDWIKI: async (params, year, month, day) => {
try {
const response = await fetch(
`https://api.wikimedia.org/feed/v1/wikipedia/en/featured/${year}/${month}/${day}`,
{
method: 'GET',
headers: {
'User-Agent': 'FuncyStr/v2.0interactive-demo',
'Content-Type': 'application/json'
}
}
);
const json = await response.json();
const title = json.tfa.titles.normalized
const url = json.tfa.content_urls.desktop.page
return `<a href="${url}">${title}</a>`
} catch (error) {
return '(NOT FOUND)';
}
}
});Interactive example
You can change and edit the textbox below to see how the system processes inputs given the commands it was given. Change the values of the pronoun select and name input to see how the system takes parameters into account.
String preview
HTML preview