Auto reformat conditionals snytax

For support and discussion related to templates, themes, and imagesets in phpBB 3.1.
Ideas Centre
Locked
zulcom
Registered User
Posts: 3
Joined: Sun Jun 10, 2018 5:46 pm

Auto reformat conditionals snytax

Post by zulcom » Sun Jun 10, 2018 6:08 pm

Hello!
Everyday i look at code formated like that:

Code: Select all

<!-- IF S_USER_LOGGED_IN and S_ZEBRA -->
<!-- IF U_REMOVE_FRIEND -->
<dt>&nbsp;</dt> <dd class="zebra"><a href="{U_REMOVE_FRIEND}" data-ajax="zebra"><strong>{L_REMOVE_FRIEND}</strong></a></dd>
<!-- ELSEIF U_REMOVE_FOE -->
<dt>&nbsp;</dt> <dd class="zebra"><a href="{U_REMOVE_FOE}" data-ajax="zebra"><strong>{L_REMOVE_FOE}</strong></a></dd>
<!-- ELSE -->
<!-- IF U_ADD_FRIEND -->
<dt>&nbsp;</dt> <dd class="zebra"><a href="{U_ADD_FRIEND}" data-ajax="zebra"><strong>{L_ADD_FRIEND}</strong></a></dd>
<!-- ENDIF -->
<!-- IF U_ADD_FOE -->
<dt>&nbsp;</dt> <dd class="zebra"><a href="{U_ADD_FOE}" data-ajax="zebra"><strong>{L_ADD_FOE}</strong></a></dd>
<!-- ENDIF -->
<!-- ENDIF -->
<!-- ENDIF -->
And i spend a lot of time to manually reformat this code to human-readable form:

Code: Select all

<!-- IF S_USER_LOGGED_IN and S_ZEBRA -->
			<!-- IF U_REMOVE_FRIEND -->
				<dt>&nbsp;</dt> 
				<dd class="zebra">
				   <a href="{U_REMOVE_FRIEND}" data-ajax="zebra">
				   <strong>{L_REMOVE_FRIEND}</strong></a>
				</dd>
			<!-- ELSEIF U_REMOVE_FOE -->
				<dt>&nbsp;</dt>
				<dd class="zebra">
				  <a href="{U_REMOVE_FOE}" data-ajax="zebra">
				     <strong>{L_REMOVE_FOE}</strong>
				   </a>
				 </dd>
			<!-- ELSE -->
				<!-- IF U_ADD_FRIEND -->
					<dt>&nbsp;</dt>
					<dd class="zebra">
					    <a href="{U_ADD_FRIEND}" data-ajax="zebra">
					    <strong>{L_ADD_FRIEND}</strong>
					    </a>
					  </dd>
				<!-- ENDIF -->
				<!-- IF U_ADD_FOE -->
					<dt>&nbsp;</dt>
					<dd class="zebra">
					  <a href="{U_ADD_FOE}" data-ajax="zebra">
					  <strong>{L_ADD_FOE}</strong>
					  </a>
					</dd>
				<!-- ENDIF -->
			<!-- ENDIF -->
<!-- ENDIF -->
So my IDE can well-format HTML files, but recognizes comments as simple comments, so just ignores all phpbb template syntax.
My question: do you really format all subsilver(or your custom) code manually?
Is any auto reformat tool for template syntax exists?

Hoping for the best
Thank you in advance for any answer

User avatar
david63
Jr. Extension Validator
Posts: 14656
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Auto reformat conditionals snytax

Post by david63 » Sun Jun 10, 2018 9:05 pm

zulcom wrote:
Sun Jun 10, 2018 6:08 pm
Is any auto reformat tool for template syntax exists?
Never seen one - but what difference does it make? The code will still be rendered correctly.
zulcom wrote:
Sun Jun 10, 2018 6:08 pm
so just ignores all phpbb template syntax.
Why do you want to ignore template syntax - it is an integral part of the template.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
Lumpy Burgertushie
Registered User
Posts: 64890
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Auto reformat conditionals snytax

Post by Lumpy Burgertushie » Sun Jun 10, 2018 9:54 pm

and what is hard about reading the code in the format you posted in the first box?

I find it easier to read than the other way. at least you don't have to scroll sideways as much.


robert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

zulcom
Registered User
Posts: 3
Joined: Sun Jun 10, 2018 5:46 pm

Re: Auto reformat conditionals snytax

Post by zulcom » Mon Jun 11, 2018 2:33 am

david63 wrote:
Sun Jun 10, 2018 9:05 pm
zulcom wrote:
Sun Jun 10, 2018 6:08 pm
Is any auto reformat tool for template syntax exists?
Never seen one - but what difference does it make? The code will still be rendered correctly.
zulcom wrote:
Sun Jun 10, 2018 6:08 pm
so just ignores all phpbb template syntax.
Why do you want to ignore template syntax - it is an integral part of the template.
Sorry for my bad English, I mean that the IDE ignores the syntax of the templates, not me.
I use template syntax and each time I spend tons of time understanding unformatted code.
I'm very upset with the lack of any tools, but in any case, thanks for the answer

zulcom
Registered User
Posts: 3
Joined: Sun Jun 10, 2018 5:46 pm

Re: Auto reformat conditionals snytax

Post by zulcom » Mon Jun 11, 2018 3:01 am

Lumpy Burgertushie wrote:
Sun Jun 10, 2018 9:54 pm
and what is hard about reading the code in the format you posted in the first box?

I find it easier to read than the other way. at least you don't have to scroll sideways as much.


robert
I break lines every time when i exceed 120 symbols per line, so any screen can display all line without sideway scroll.
But when you read conditional block you need to remember all of condtitionals, where it starts and where it ends.
Besides, space formatting conditional block is industry standard of code style.
You can remove all gaps from start of every line in for example PHP code and say that is fantastic useful and human-readable,
your team can deal with it, but that means nothing when you see tears of new devepoler in your crew.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51326
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Auto reformat conditionals snytax

Post by Brf » Mon Jun 11, 2018 12:17 pm

There are not any tools because the phpBB pages are all generated dynamically, using the data in the database. Your "tool" would have to run all of the PHP scripts to generate the page. It is simpler just to browse to it and let the phpBB code do all the work.

User avatar
canonknipser
Registered User
Posts: 1601
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Auto reformat conditionals snytax

Post by canonknipser » Mon Jun 11, 2018 3:53 pm

Brf, I think you're missing one part: the OP is talking about working as a style developer, adapting and changing style files.
As a developer, it is a big advantage to have proper formatted code in your editor.
For automatic code formatting, it is bad that phpBB-template syntax is written as html comments, so commands following conditionals like IF, ELSE are not indented as in "normal" code.

Maybe if the OP would switch to TWIG syntax when creating styles - TWIG is commonly used an often available as a code highlighter for editors.
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51326
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Auto reformat conditionals snytax

Post by Brf » Mon Jun 11, 2018 3:55 pm

Ah. So all he is looking for is the highlighting and indents. I get it.

User avatar
3Di
Registered User
Posts: 12903
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Auto reformat conditionals snytax

Post by 3Di » Tue Jun 12, 2018 5:32 am

Lumpy Burgertushie wrote:
Sun Jun 10, 2018 9:54 pm
and what is hard about reading the code in the format you posted in the first box?
It's hard, not a good practise at all as well.
When a code becomes unreadable (coder-wise speaking) it's badly coded, also if it does what's written on the tin.
Lumpy Burgertushie wrote:
Sun Jun 10, 2018 9:54 pm
I find it easier to read than the other way. at least you don't have to scroll sideways as much.
Exception I can say. Also it seems to me you missed till now to use the word-wrap facility in your editor.
zulcom wrote:
Mon Jun 11, 2018 3:01 am
But when you read conditional block you need to remember all of condtitionals, where it starts and where it ends.
Besides, space formatting conditional block is industry standard of code style.
You can remove all gaps from start of every line in for example PHP code and say that is fantastic useful and human-readable,
your team can deal with it, but that means nothing when you see tears of new devepoler in your crew.
Correct.
canonknipser wrote:
Mon Jun 11, 2018 3:53 pm
As a developer, it is a big advantage to have proper formatted code in your editor.
For automatic code formatting, it is bad that phpBB-template syntax is written as html comments, so commands following conditionals like IF, ELSE are not indented as in "normal" code.

Maybe if the OP would switch to TWIG syntax when creating styles - TWIG is commonly used an often available as a code highlighter for editors.
Exactly.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
canonknipser
Registered User
Posts: 1601
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Auto reformat conditionals snytax

Post by canonknipser » Tue Jun 12, 2018 12:44 pm

phpBB, as the name gives a hint, written in php, some parts in the html based fronted (templated files) contain small javascript snipplets. So this
zamakli wrote:
Tue Jun 12, 2018 12:05 pm
sonar violations in a large legacy java code-base
has nothing to do with phpBB and it's coding of template files, esp. when it comes to sonar (cube / source /...) product checks.
For your question
zamakli wrote:
Tue Jun 12, 2018 12:05 pm
Does anybody know of a tool that could perform a bulk operation like this?
I would recommend to look at sonar support sides
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

User avatar
david63
Jr. Extension Validator
Posts: 14656
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Auto reformat conditionals snytax

Post by david63 » Tue Jun 12, 2018 2:25 pm

Also bear in mind that phpBB templates will be moving over to Twig syntax
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

Locked

Return to “[3.1.x] Styles Support & Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests