Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{{#if symbol.members.[0].doc.brief}}

{{symbol.members.[0].doc.brief}}
{{{symbol.members.[0].doc.brief}}}

{{/if}}

Expand All @@ -23,7 +23,7 @@
{{#if symbol.members.[0].doc.description}}
=={{#unless @root.config.multipage}}={{/unless}} Description

{{symbol.members.[0].doc.description}}
{{{symbol.members.[0].doc.description}}}
{{/if}}

{{#with (flattenUnique symbol.members "doc.exceptions" "exception") as |allExceptions|}}
Expand All @@ -35,7 +35,7 @@

{{#each allExceptions as |exception|}}
| `{{exception.exception}}`
| {{exception.description}}
| {{{exception.description}}}
{{/each}}
|===
{{/if}}
Expand All @@ -44,7 +44,7 @@
{{#if symbol.members.[0].doc.returns}}
=={{#unless @root.config.multipage}}={{/unless}} Return Value

{{symbol.members.[0].doc.returns}}
{{{symbol.members.[0].doc.returns}}}

{{/if}}

Expand All @@ -67,7 +67,7 @@
=={{#unless @root.config.multipage}}={{/unless}} Preconditions

{{#each symbol.members.[0].doc.preconditions}}
{{.}}
{{{.}}}
{{/each}}

{{/if}}
Expand All @@ -76,7 +76,7 @@
=={{#unless @root.config.multipage}}={{/unless}} Postconditions

{{#each symbol.members.[0].doc.postconditions}}
{{.}}
{{{.}}}
{{/each}}

{{/if}}
Expand All @@ -85,7 +85,7 @@
=={{#unless @root.config.multipage}}={{/unless}} See Also

{{#each symbol.members.[0].doc.see}}
{{.}}
{{{.}}}
{{/each}}
{{/if}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{{#each symbol.members as |member|}}

<p>{{member.doc.brief}}</p>
<p>{{{member.doc.brief}}}</p>

<pre><code class="language-cpp">{{> (concat 'signature' '/' (lookup member 'kind')) symbol=member}};</code></pre>
<a href="{{{relativize member.url}}}"><em>» more...</em></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- alias --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- concept --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent includeNamespace=true}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- enum --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>{{#if symbol.name}}Enum {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}{{else}}Unnamed enum{{/if}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- enumerator --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>Enumerator {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- field --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- friend --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>Friend {{#if symbol.symbol}}{{symbol.symbol.name}}{{else}}{{symbol.type.name}}{{/if}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- function --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>Function {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- guides --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>Deduction guide {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- namespace --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>{{#if symbol.name}}Namespace {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}{{else if symbol.parent}}Unnamed namespace{{else}}Global namespace{{/if}}</h2>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- record --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>{{#if symbol.name}}Class {{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}{{else}}Unnamed class{{/if}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- typedef --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- symbols/using.html.hbs --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>Using {{#if (eq symbol.class "namespace")}}Directive: {{symbol.qualifier.name}}{{else}}Declaration: {{symbol.name}}{{/if}}</h2>
{{{symbol.doc.brief}}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{!-- variable --}}
<div id="{{symbol.anchor}}">
<div id="{{{symbol.anchor}}}">
<div>
<h2>{{>types/nested-name-specifier symbol=symbol.parent}}{{symbol.name}}</h2>
{{{symbol.doc.brief}}}
Expand Down
86 changes: 59 additions & 27 deletions src/lib/Support/Handlebars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4014,48 +4014,80 @@ at_fn(dom::Value range, dom::Value field, dom::Value options)
}
}

dom::Value
concat_fn(
dom::Value range1,
dom::Value sep,
dom::Value range2,
dom::Value options)
Expected<dom::Value>
concat_fn(dom::Array const& arguments)
{
auto isBlock = options.isUndefined() && static_cast<bool>(range2.get("fn"));
dom::Value options = arguments.back();
dom::Value fn = options.get("fn");
auto const isBlock = static_cast<bool>(fn);
if (isBlock)
{
options = range2;
range2 = sep;
sep = range1;
range1 = options.get("fn")();
// Block overload: concatenate the contents of the
// block with the contents of the arguments as strings.
std::string str = static_cast<std::string>(fn());
for (std::size_t i = 0; i < arguments.size() - 1; ++i)
{
str += toString(arguments.get(i));
}
return str;
}

if (range1.isString() || range2.isString())
// Check if we have at least one argument besides the options
if (arguments.size() == 1)
{
return range1 + sep + range2;
return Unexpected(Error("#concat requires at least one argument"));
}
else if (range1.isArray() && sep.isArray())

dom::Value firstArg = arguments.get(0);

// Array overload: concatenate all arguments a single array.
if (firstArg.isArray())
{
options = range2;
range2 = sep;
dom::Array res;
for (dom::Value item : range1.getArray())
for (std::size_t i = 0; i < arguments.size() - 1; ++i)
{
res.emplace_back(item);
dom::Value arg = arguments.get(i);
if (arg.isArray())
{
for (dom::Value item : arg.getArray())
{
res.emplace_back(item);
}
}
else
{
res.emplace_back(arg);
}
}
for (dom::Value item : range2.getArray())
return res;
}

// Object overload: concatenate all arguments into a single object.
if (firstArg.isObject())
{
dom::Object res = firstArg.getObject();
for (std::size_t i = 1; i < arguments.size() - 1; ++i)
{
res.emplace_back(item);
dom::Value arg = arguments.get(i);
if (arg.isObject())
{
res = createFrame(arg.getObject(), res);
}
else
{
return Unexpected(Error("All arguments to #concat must be objects"));
}
}
return res;
}
else if (range1.isObject() && sep.isObject())

// String overload: concatenate all arguments as strings.
std::string str;
for (std::size_t i = 0; i < arguments.size() - 1; ++i)
{
options = range2;
range2 = sep;
return createFrame(range1.getObject(), range2.getObject());
str += toString(arguments.get(i));
}
return range1 + range2;
return str;
}

std::int64_t
Expand Down Expand Up @@ -5107,7 +5139,7 @@ registerStringHelpers(Handlebars& hbs)
hbs.registerHelper("join", join_fn);
hbs.registerHelper("implode", join_fn);

hbs.registerHelper("concat", dom::makeInvocable(concat_fn));
hbs.registerHelper("concat", dom::makeVariadicInvocable(concat_fn));

static auto strip_fn = dom::makeVariadicInvocable([](
dom::Array const& arguments)
Expand Down Expand Up @@ -6570,7 +6602,7 @@ registerContainerHelpers(Handlebars& hbs)
return res2;
}));

hbs.registerHelper("concat", dom::makeInvocable(concat_fn));
hbs.registerHelper("concat", dom::makeVariadicInvocable(concat_fn));

static auto flatten_fn = dom::makeInvocable([](dom::Value const& collection, dom::Value const& key) -> dom::Value
{
Expand Down
Loading