<aside> 💡 Owner: @Marcin Hagmajer

</aside>

AskJSX is presented as a subset of JSX - XML-like extension to ECMAScript. For simplicity it's presented however as a JSON of this form. More examples at the bottom of the page.

// as define by AskCode; [] - stands for array(...)

{
	name: string,
	props: map(string, AskCode),
  children: [AskCode],
}

Type

Elements

Examples

Accessing resources

ask {
	hello
}
<ask>
	<ref name="hello" />
</ask>

Creating values

ask {
	"Hello world!"
}
<ask>
	<string>Hello world</string>
</ask>

Creating functions

ask {
	const factorial = (n:int): int {
		if (n:lessThan(2)) {
			return n
		}
		n:times:factorial(n:minus(1))
	}
	
	score :factorial
}
<ask>
  <fun
		name="factorial"
		args={[['n', <int />]]}
		returns={<int />}
	>
    <if
			condition={
				<call name="lessThan" args={[2]} />
			}
		>			
      <return value={<ref name="n" />} />
    </if>
		<call name="times" args={[
			<ref name="n" />,
			<call name="factorial" args={[
				<call name="minus" args={[
					<ref name="n" />,
					1,
				]} />,
			]} />,
		]} />
	</fun>
	<call name="factorial" args={[
		<ref name="score" />
	]} />
</ask>

Query

ask {
	query {
		lastName		
		fullName :firstName :concat(' ', lastName) :upperCase
	}
}
<ask>
	<query>
		<field name="lastName" />
		<field name="fullName">
			<call name="upperCase">
				<call name="concat">
					{' '}
					<ref name="lastName" />
				</call>
				<call name="firstName">
					<ref name="value" />
				</call>				
			</call>	
		</field>
	</query>
</ask>

@Marcin Hagmajer , jak wyglÄ…da <ask>, gdy sÄ… zadeklarowane argumenty i typ zwracany?