<p>I've tested these three methods (the first one from AbbeyDesign's answer,) and they seem to work fine with variables, I can't see any obvious reason why they wouldn't:</p>

<pre><code>{% set entry = { artistFirstName: 'hello', title: 'world' } %}

{% set title = (entry.artistFirstName|capitalize) ~ ' ' ~ (entry.title|capitalize) %}
{% set title = "#{entry.artistFirstName|capitalize} #{entry.title|capitalize}" %}
{% set title = [entry.artistFirstName|capitalize, entry.title|capitalize]|join(' ') %}
</code></pre>

<p>Results in "Hello World" in each case.</p>

CC BY-SA 3.0
2014-09-17T20:12:49.023Z
That's really strange, I tried each of your methods but each always results 'Hello world'. Note that I use this to set the <title> attribute, at the top of my _entry.html. I'm not trying to add this inside a {% block content %}. Perhaps that's why it's not working in my case?
Romain P.
CC BY-SA 3.0
2014-09-18T00:00:44.717Z
If you're not sure about whether the block is an issue or not, it may be worth testing these on a page that isn't using extends/block/set or whatever.  Give them a shot on a basic page and try to complicate things afterwards.  In my tests, the syntax for these is working just fine as well so it's likely a larger context issue.
Ben Parizek
CC BY-SA 3.0
2014-09-17T12:00:34.960Z
2014-09-17T12:00:34.960Z
Mike Pepper
<pre><code>{% set title = (entry.artistFirstName|capitalize) ~ ' ' ~ (entry.title|capitalize) %}
</code></pre>

CC BY-SA 3.0
2014-09-16T20:09:40.560Z
Sorry, this doesn't work for me.
Romain P.
CC BY-SA 3.0
2014-09-16T19:55:35.270Z
2014-09-16T19:55:35.270Z
AbbeyDesign
<p>Here's an example:</p>

<pre><code>{% set title = entry.artistFirstName | capitalize ~ ' ' ~ entry.title | capitalize %}
</code></pre>

<p>It outputs <em>Firstname title</em> instead of <em>Firstname Title</em> whereas filters are applied on the two concatenated elements. Why and how to add this filter on each of these elements?</p>

CC BY-SA 3.0
2014-09-17T01:44:10.670Z
Does it work as expected if you just use plain text?: {% set title = 'lowercase this' | capitalize ~ ' ' ~ 'lowercase that' | capitalize %}
Ben Parizek
CC BY-SA 3.0
2014-09-17T20:14:37.440Z
No: 'Lowercase this lowercase that'.
Romain P.
<filter><titles>
How to apply a filter on a title with several concatenated elements?
# How to apply a filter on a title with several concatenated elements?

(Asked by: username_0 on 2014-09-16)

Here's an example:
{% set title = entry.artistFirstName | capitalize ~ ' ' ~ entry.title | capitalize %}

It outputs Firstname title instead of Firstname Title whereas filters are applied on the two concatenated elements. Why and how to add this filter on each of these elements?

**Tags:** filter, titles
> **Comments:**
> **username_1**: Does it work as expected if you just use plain text?: {% set title = 'lowercase this' | capitalize ~ ' ' ~ 'lowercase that' | capitalize %}  
> **username_0**: No: 'Lowercase this lowercase that'.  

---

## 2 answers

### Answer by username_2 on 2014-09-17. Score: 3

I've tested these three methods (the first one from AbbeyDesign's answer,) and they seem to work fine with variables, I can't see any obvious reason why they wouldn't:
{% set entry = { artistFirstName: 'hello', title: 'world' } %}

{% set title = (entry.artistFirstName|capitalize) ~ ' ' ~ (entry.title|capitalize) %}
{% set title = "#{entry.artistFirstName|capitalize} #{entry.title|capitalize}" %}
{% set title = [entry.artistFirstName|capitalize, entry.title|capitalize]|join(' ') %}

Results in "Hello World" in each case.

> **Comments:**
> **username_0**: That's really strange, I tried each of your methods but each always results 'Hello world'. Note that I use this to set the <title> attribute, at the top of my _entry.html. I'm not trying to add this inside a {% block content %}. Perhaps that's why it's not working in my case?  
> **username_1**: If you're not sure about whether the block is an issue or not, it may be worth testing these on a page that isn't using extends/block/set or whatever.  Give them a shot on a basic page and try to complicate things afterwards.  In my tests, the syntax for these is working just fine as well so it's likely a larger context issue.  

---

### Answer by username_3 on 2014-09-16. Score: 0

{% set title = (entry.artistFirstName|capitalize) ~ ' ' ~ (entry.title|capitalize) %}

> **Comments:**
> **username_0**: Sorry, this doesn't work for me.  

---

