Project

General

Profile

Actions

Feature #23762

closed

Typoscript issue on values using "internal chars" in string-sequence

Added by Gabriel Kaufmann over 13 years ago. Updated over 9 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2010-12-30
Due date:
% Done:

0%

Estimated time:
PHP Version:
5.3
Tags:
Complexity:
Sprint Focus:

Description

I noticed that TYPO3 seems to have problems on using internal-chars within dataWrap'ped typoscript-values.

Internal-Chars are f.e.:
the pipe "|"
curls like ( ) { }

The only "hack" figured out by myself is to use a LOAD_REGISTER where ever possible to avoid using the chars them-self within Typoscript values/wraps.

There should be a more programmer friendly way to solve this!

My recommendation: Make Typoscript handle "escapes" like they work in RegEXP (escape-sequences f.e. "\").

f.e. output curls: \{ \( <-- THESE WILL BE HANDLED AS TEXT IN TS!

Example:

DOES NOT WORK:

-- TS-Setup --
10 = TEXT
10.dataWrap = {THIS SHOULD BE SHOWN AS TEXT WITH CURL}

20 = TEXT
20.dataWrap (
<script language="text/javascript">
// Curls may be very annoing using Javascript with InsertData/Registers in Typoscript!!!
// example:
function test() {
// THIS WILL NOT RENDER CORRECTLY WITH CURLS!
}

// another example:
var JSON={value:test} // CRASH: DOES NOT RENDER OUT AS SHOWN HERE!
&lt;/script&gt;
)

DOES WORK
10 = COA
10.1 = LOAD_REGISTER
10.1.openCurl = {
10.1.closeCurl = }

10.10 = TEXT
10.10.dataWrap = {register:openCurl}THIS SHOULD BE SHOWN AS TEXT WITH CURL{register:closeCurl}

20.20 = TEXT
20.20.dataWrap (
<script language="text/javascript">
// Curls may be very annoing using Javascript with InsertData/Registers in Typoscript!!!
// example:
function test() {register:openCurl}
// THIS HACK WILL WORK! {register:closeCurl}

// another example:
var JSON={register:openCurl}value:test{register:closeCurl}
&lt;/script&gt;
)

I hope this Hack will work for anybody having the issue like me.
(issue imported from #M16881)


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #24391: Bing Webmaster Tools metatag does not workRejected2010-12-22

Actions
Actions #1

Updated by Gabriel Kaufmann over 13 years ago

I can't provide a patch yet as I wasn't able to "dig" into the TYPO3-Core for rendering Typoscript yet ;-)

I hope there will be a core-developer reading this who is able to provide a patch out of his hands very quick instead.

Actions #2

Updated by Jo Hasenau over 13 years ago

As long as you don't provide any data to be inserted within the dataWrap, you should not use it anyway.

10 = TEXT
10.dataWrap = {THIS SHOULD BE SHOWN AS TEXT WITH CURL}

no need for a dataWrap here, since this would be done by

10 = TEXT
10.value = {THIS SHOULD BE SHOWN AS TEXT WITH CURL}

same with the second example. There is no data to be inserted, so you should go for "value" instead of "dataWrap"

Of course there might be situations where you would have to insert data and use curly braces as well, but this could be solved easily like this:

10 = COA
10 {
10 = TEXT
10 {
field = fieldname
dataWrap = | {field:another_fieldname}
wrap3 = {|}
}
20 = TEXT
20 {
field = yet_another_fieldname
dataWrap = |{field:a_last_fieldname}
wrap3 = {|}
}
}

Actions #3

Updated by Gabriel Kaufmann over 13 years ago

@ Jo Hasenau (reporter)

I totally agree, that some of my examples wouldn't need a dataWrap. These examples were not correct. In fact in each of the dataWrap's there should be any data-values which makes sense for the dataWrap-use instead of a plain value!

Thank you for your suggestion using wrap3 for the curls. But in fact there are situations which will make the typoscript unnessecarily blow-up because of that syntax. Imagine the rendering of more-complex javascript that has to be rendered using typoscript instead of static-inclusion. I don't think it would make sense to use hundred of COA and TEXT-wrap to solve the curls.

Of couse in usual way it makes sense to use static-external javascripts where ever possible. Also there shouldn't be more dataWrap than really needed (for performance reasons). But in some case this happens for complex data that has to be rendered into javascript-structures.

So why wouldn't it make sense to think about escaping for typoscript-internal values?

Actions #4

Updated by Jo Hasenau over 13 years ago

If you want to provide JavaScript with some values inserted, this would be a job for the TEMPLATE element. Just use your JS as the template file and fill in some markers to be replaced with the dynamic values.

Of course it could make sense to escape "internal" characters while parsing TypoScript, but I don't see too many use cases, that could not be solved easily with the current parser and some existing elements.

Actions #5

Updated by d.ros no-lastname-given about 11 years ago

  • Target version deleted (0)

HereĀ“s the usecase that should be common -> JS Libraries from CDN and their fallback.

masterscripts.allWrap = <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><script>window.jQuery &124;&124; document.write('<script src="fileadmin/developer/Templates/mcdn/jquery/jquery.min.1.7.2.js"><\script>')</script> |

Masking with

&124;
works buts V8 from Chrome matches an illigal character.

Cheers

Actions #6

Updated by Mathias Schreiber over 9 years ago

  • Tracker changed from Bug to Feature
  • Description updated (diff)
  • Status changed from New to Rejected

Sorry, but implementing this is just too big of a task while there are plenty of alternatives around.
You can use TEMPLATE, FLUIDTEMPLATE etc for these kinds of things.
The Typoscript Parser is a brittle, gigantic thing.

I had a look at this in regards of the escape sequence idea but that way we'd need to fiddle around with the strings or regex things.
I tried escaping { and it resulted in more than 50% rendering overhead.

Sorry for the bad news, but no... can't be done.

Actions

Also available in: Atom PDF