How to delete an attribute in ts2 > prototype?

I would like to output the attribute e.g. «id» only as HTML-Tag in sourceCode, if there is a value (string) in the nodeType Attribute.
Unfortunately, if I don’t set a string before and delete this later, there appears a tag «id» in Source without value:
First [div] is without id-set before, second is set and after delete.

####The code in .ts2

prototype(Vendor.Site:NodeTypeName) < prototype(TYPO3.Neos:Content) {
		id = ${(q(node).property('id') ?  q(node).property('id') : '' )}
		id.@if.condition = ${q(node).property('id') !=''}		

It works fine, when I delete a set string. The «id»-tag dosen’t appear in source Code. But without set and delete there is an empty «id» in SourceCode.

Is there a way to check, if in «id» attribute is not an empty string AND «id» is not totally empty?
get’s a
'class="testclass" id'

Maybe there is an easier way to check if in an attribute is to output in html-sourceCode?

Hey Martin,

I don’t now if I get you totally right - because I do not see the where you actually “delete” the id. But the following code should be the leanest way to do it:

prototype(Vendor.Site:NodeTypeName) < prototype(TYPO3.Neos:Content) {
		id = ${q(node).property('id')}
		id.@if.condition = ${q(node).property('id') != ''}		
1 Like

If I understand you correctly, you can make the check more loose instead of checking if it’s an empty string.

id.@if.condition = ${q(node).property('id') ? true : false}

or be more specific

id.@if.condition = ${q(node).property('id') != '' && q(node).property('id') != null ? true : false}
1 Like

Thank you both.

It was a missunderstood of mine. I thought «@if.condition = false» would delete the property.
Now, I see the meaning of «to prevent evaluation of the value» in the docs more clear – but still not in details… what remains?
Can’t find the @…-Logic in Neos-Code or PHP docs; there only for comments. Maybe there I would find something like php’s unset().

Would property «id» delted with «>» the angular (angle) bracket to the right?

id >

(The bracket-search in google for TypoScript or TypoScript2 is really ingloriously)

And if it would delete the property, how I coud combine this with condition? Or is it not possible/necessary to delete a property with conditions, processors or other typoscript stuff? Because in the end is just one important: the output…

With your both help, there is no empty «id» left in sourceCode. Great!