[Brainstorming] Best practices on indentation for rendering macros in scripts

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[Brainstorming] Best practices on indentation for rendering macros in scripts

vmassol
Administrator
Hi,

Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
Context 2: Fill the “velocity code style” section of http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/

Option A-1: No top level indentation
=========================

{{velocity}}
#set ($var = …)
#if (…)
  …
  #if (…)
  #end
#end
{{/velocity}}

Nested example:

{{velocity}}
#if ($doc.fullName != 'XWiki.AdminInlineSheet')
  #set($formname = 'inline')
  #set($saveaction = 'save')
  #set($previewenabled = true)
  #set($xnotification = $!request.getParameter('xnotification'))
  {{html}}
  <form id="inline" method="post" action="$doc.getURL('preview’)">
    <div>
    …
{{/velocity}}

Pros:
* This is what we currently do which IMO means it’s the more natural way
* Makes content more visible when editing inside xwiki since it takes less horizontal space
* Less typing and less chance to make it wrong

Option A-2: Top level indentation
========================

{{velocity}}
  #set ($var = …)
  #if (…)
    …
    #if (…)
    #end
  #end
{{/velocity}}

Nested example:

{{velocity}}
  #if ($doc.fullName != 'XWiki.AdminInlineSheet')
    #set($formname = 'inline')
    #set($saveaction = 'save')
    #set($previewenabled = true)
    #set($xnotification = $!request.getParameter('xnotification'))
    {{html}}
      <form id="inline" method="post" action="$doc.getURL('preview’)">
        <div>
        …
{{/velocity}}

Pros:
* More logical since a macro is a container (even though it’s different syntax - wiki markup vs velocity - so it’s arguable)
* More legible?

Cons
* This means slowly changing everywhere we use scripting.

WDYT?

I think my preference goes to A-1 FTM since I’ve never thought to myself that it was an issue all these years of using it.

Thanks
-Vincent


Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Adel Atallah
I don't think we need top level indentation to make it clear that a
macro is being used so I would go for option A-1.


On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]> wrote:

> Hi,
>
> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> Context 2: Fill the “velocity code style” section of http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
>
> Option A-1: No top level indentation
> =========================
>
> {{velocity}}
> #set ($var = …)
> #if (…)
>   …
>   #if (…)
>   #end
> #end
> {{/velocity}}
>
> Nested example:
>
> {{velocity}}
> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>   #set($formname = 'inline')
>   #set($saveaction = 'save')
>   #set($previewenabled = true)
>   #set($xnotification = $!request.getParameter('xnotification'))
>   {{html}}
>   <form id="inline" method="post" action="$doc.getURL('preview’)">
>     <div>
>     …
> {{/velocity}}
>
> Pros:
> * This is what we currently do which IMO means it’s the more natural way
> * Makes content more visible when editing inside xwiki since it takes less horizontal space
> * Less typing and less chance to make it wrong
>
> Option A-2: Top level indentation
> ========================
>
> {{velocity}}
>   #set ($var = …)
>   #if (…)
>     …
>     #if (…)
>     #end
>   #end
> {{/velocity}}
>
> Nested example:
>
> {{velocity}}
>   #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>     #set($formname = 'inline')
>     #set($saveaction = 'save')
>     #set($previewenabled = true)
>     #set($xnotification = $!request.getParameter('xnotification'))
>     {{html}}
>       <form id="inline" method="post" action="$doc.getURL('preview’)">
>         <div>
>         …
> {{/velocity}}
>
> Pros:
> * More logical since a macro is a container (even though it’s different syntax - wiki markup vs velocity - so it’s arguable)
> * More legible?
>
> Cons
> * This means slowly changing everywhere we use scripting.
>
> WDYT?
>
> I think my preference goes to A-1 FTM since I’ve never thought to myself that it was an issue all these years of using it.
>
> Thanks
> -Vincent
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Thomas Mortagne
Administrator
In reply to this post by vmassol
I'm OK with both but I prefer A-2 which is more readable and more logical IMO.

On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]> wrote:

> Hi,
>
> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> Context 2: Fill the “velocity code style” section of http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
>
> Option A-1: No top level indentation
> =========================
>
> {{velocity}}
> #set ($var = …)
> #if (…)
>   …
>   #if (…)
>   #end
> #end
> {{/velocity}}
>
> Nested example:
>
> {{velocity}}
> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>   #set($formname = 'inline')
>   #set($saveaction = 'save')
>   #set($previewenabled = true)
>   #set($xnotification = $!request.getParameter('xnotification'))
>   {{html}}
>   <form id="inline" method="post" action="$doc.getURL('preview’)">
>     <div>
>     …
> {{/velocity}}
>
> Pros:
> * This is what we currently do which IMO means it’s the more natural way
> * Makes content more visible when editing inside xwiki since it takes less horizontal space
> * Less typing and less chance to make it wrong
>
> Option A-2: Top level indentation
> ========================
>
> {{velocity}}
>   #set ($var = …)
>   #if (…)
>     …
>     #if (…)
>     #end
>   #end
> {{/velocity}}
>
> Nested example:
>
> {{velocity}}
>   #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>     #set($formname = 'inline')
>     #set($saveaction = 'save')
>     #set($previewenabled = true)
>     #set($xnotification = $!request.getParameter('xnotification'))
>     {{html}}
>       <form id="inline" method="post" action="$doc.getURL('preview’)">
>         <div>
>         …
> {{/velocity}}
>
> Pros:
> * More logical since a macro is a container (even though it’s different syntax - wiki markup vs velocity - so it’s arguable)
> * More legible?
>
> Cons
> * This means slowly changing everywhere we use scripting.
>
> WDYT?
>
> I think my preference goes to A-1 FTM since I’ve never thought to myself that it was an issue all these years of using it.
>
> Thanks
> -Vincent
>
>



--
Thomas Mortagne
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Eduard Moraru
+1 for A-2, since I find it more consistent and logical for an element that
accepts inner content to indent that content, once it spans on multiple
lines (since you can also have the inline version). It would be consistent
with the indentation policy we apply for HTML as well.

I can't find many arguments for making an exception for them, other than
the fact that the velocity and HTML macros tend to be used quite loosely
(i.e. pages with entire content wrapped by a start and end velocity macro),
but we are talking generally about all rendering macros, so I think it
makes sense to indent. The SyntaxHighlighting enabled wiki editor also
helps in indenting multiple lines at the same time.

Note: One thing that I remember that needs fixing in the SH enabled editor
is the "decrease indentation" operation (i.e. SHIFT+TAB should decrease the
indentation of the selected lines by one level) which is now configured to
do "auto-indentation" instead (i.e. indent the lines to the level dictated
by the context, a bit similar to the "Auto-Formatting" option in Eclipse,
or other IDEs). However, I don't remember hearing many people complain
about this yet, so maybe it's not that painful, but would still need fixing.

Thanks,
Eduard

On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <[hidden email]>
wrote:

> I'm OK with both but I prefer A-2 which is more readable and more logical
> IMO.
>
> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]>
> wrote:
> > Hi,
> >
> > Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> > Context 2: Fill the “velocity code style” section of
> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
> >
> > Option A-1: No top level indentation
> > =========================
> >
> > {{velocity}}
> > #set ($var = …)
> > #if (…)
> >   …
> >   #if (…)
> >   #end
> > #end
> > {{/velocity}}
> >
> > Nested example:
> >
> > {{velocity}}
> > #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> >   #set($formname = 'inline')
> >   #set($saveaction = 'save')
> >   #set($previewenabled = true)
> >   #set($xnotification = $!request.getParameter('xnotification'))
> >   {{html}}
> >   <form id="inline" method="post" action="$doc.getURL('preview’)">
> >     <div>
> >     …
> > {{/velocity}}
> >
> > Pros:
> > * This is what we currently do which IMO means it’s the more natural way
> > * Makes content more visible when editing inside xwiki since it takes
> less horizontal space
> > * Less typing and less chance to make it wrong
> >
> > Option A-2: Top level indentation
> > ========================
> >
> > {{velocity}}
> >   #set ($var = …)
> >   #if (…)
> >     …
> >     #if (…)
> >     #end
> >   #end
> > {{/velocity}}
> >
> > Nested example:
> >
> > {{velocity}}
> >   #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> >     #set($formname = 'inline')
> >     #set($saveaction = 'save')
> >     #set($previewenabled = true)
> >     #set($xnotification = $!request.getParameter('xnotification'))
> >     {{html}}
> >       <form id="inline" method="post" action="$doc.getURL('preview’)">
> >         <div>
> >         …
> > {{/velocity}}
> >
> > Pros:
> > * More logical since a macro is a container (even though it’s different
> syntax - wiki markup vs velocity - so it’s arguable)
> > * More legible?
> >
> > Cons
> > * This means slowly changing everywhere we use scripting.
> >
> > WDYT?
> >
> > I think my preference goes to A-1 FTM since I’ve never thought to myself
> that it was an issue all these years of using it.
> >
> > Thanks
> > -Vincent
> >
> >
>
>
>
> --
> Thomas Mortagne
>
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

vmassol
Administrator


> On 6 Jun 2018, at 12:37, Eduard Moraru <[hidden email]> wrote:
>
> +1 for A-2, since I find it more consistent and logical for an element that
> accepts inner content to indent that content, once it spans on multiple
> lines (since you can also have the inline version). It would be consistent
> with the indentation policy we apply for HTML as well.
>
> I can't find many arguments for making an exception for them, other than
> the fact that the velocity and HTML macros tend to be used quite loosely
> (i.e. pages with entire content wrapped by a start and end velocity macro),
> but we are talking generally about all rendering macros, so I think it
> makes sense to indent. The SyntaxHighlighting enabled wiki editor also
> helps in indenting multiple lines at the same time.
>
> Note: One thing that I remember that needs fixing in the SH enabled editor
> is the "decrease indentation" operation (i.e. SHIFT+TAB should decrease the
> indentation of the selected lines by one level) which is now configured to
> do "auto-indentation" instead (i.e. indent the lines to the level dictated
> by the context, a bit similar to the "Auto-Formatting" option in Eclipse,
> or other IDEs). However, I don't remember hearing many people complain
> about this yet, so maybe it's not that painful, but would still need fixing.

Well on my side I curse the syntax highlighting almost every single day… :(

Honestly, right now, I would very much prefer to just disable it by default.

I do lots of testing every day, using velocity and groovy macros and the indentation costs me way too much time than it should, especially for macro closing. In my use cases the coloring is a nice to have but it’s not really needed (I only have a few lines) but the extra keystrokes needed for unindenting are a pain.

Thanks
-Vincent

>
> Thanks,
> Eduard
>
> On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <[hidden email]>
> wrote:
>
>> I'm OK with both but I prefer A-2 which is more readable and more logical
>> IMO.
>>
>> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]>
>> wrote:
>>> Hi,
>>>
>>> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
>>> Context 2: Fill the “velocity code style” section of
>> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
>>>
>>> Option A-1: No top level indentation
>>> =========================
>>>
>>> {{velocity}}
>>> #set ($var = …)
>>> #if (…)
>>>  …
>>>  #if (…)
>>>  #end
>>> #end
>>> {{/velocity}}
>>>
>>> Nested example:
>>>
>>> {{velocity}}
>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>>>  #set($formname = 'inline')
>>>  #set($saveaction = 'save')
>>>  #set($previewenabled = true)
>>>  #set($xnotification = $!request.getParameter('xnotification'))
>>>  {{html}}
>>>  <form id="inline" method="post" action="$doc.getURL('preview’)">
>>>    <div>
>>>    …
>>> {{/velocity}}
>>>
>>> Pros:
>>> * This is what we currently do which IMO means it’s the more natural way
>>> * Makes content more visible when editing inside xwiki since it takes
>> less horizontal space
>>> * Less typing and less chance to make it wrong
>>>
>>> Option A-2: Top level indentation
>>> ========================
>>>
>>> {{velocity}}
>>>  #set ($var = …)
>>>  #if (…)
>>>    …
>>>    #if (…)
>>>    #end
>>>  #end
>>> {{/velocity}}
>>>
>>> Nested example:
>>>
>>> {{velocity}}
>>>  #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>>>    #set($formname = 'inline')
>>>    #set($saveaction = 'save')
>>>    #set($previewenabled = true)
>>>    #set($xnotification = $!request.getParameter('xnotification'))
>>>    {{html}}
>>>      <form id="inline" method="post" action="$doc.getURL('preview’)">
>>>        <div>
>>>        …
>>> {{/velocity}}
>>>
>>> Pros:
>>> * More logical since a macro is a container (even though it’s different
>> syntax - wiki markup vs velocity - so it’s arguable)
>>> * More legible?
>>>
>>> Cons
>>> * This means slowly changing everywhere we use scripting.
>>>
>>> WDYT?
>>>
>>> I think my preference goes to A-1 FTM since I’ve never thought to myself
>> that it was an issue all these years of using it.
>>>
>>> Thanks
>>> -Vincent
>>>
>>>
>>
>>
>>
>> --
>> Thomas Mortagne
>>

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

vmassol
Administrator


> On 6 Jun 2018, at 13:24, Vincent Massol <[hidden email]> wrote:
>
>
>
>> On 6 Jun 2018, at 12:37, Eduard Moraru <[hidden email]> wrote:
>>
>> +1 for A-2, since I find it more consistent and logical for an element that
>> accepts inner content to indent that content, once it spans on multiple
>> lines (since you can also have the inline version). It would be consistent
>> with the indentation policy we apply for HTML as well.
>>
>> I can't find many arguments for making an exception for them, other than
>> the fact that the velocity and HTML macros tend to be used quite loosely
>> (i.e. pages with entire content wrapped by a start and end velocity macro),
>> but we are talking generally about all rendering macros, so I think it
>> makes sense to indent. The SyntaxHighlighting enabled wiki editor also
>> helps in indenting multiple lines at the same time.
>>
>> Note: One thing that I remember that needs fixing in the SH enabled editor
>> is the "decrease indentation" operation (i.e. SHIFT+TAB should decrease the
>> indentation of the selected lines by one level) which is now configured to
>> do "auto-indentation" instead (i.e. indent the lines to the level dictated
>> by the context, a bit similar to the "Auto-Formatting" option in Eclipse,
>> or other IDEs). However, I don't remember hearing many people complain
>> about this yet, so maybe it's not that painful, but would still need fixing.
>
> Well on my side I curse the syntax highlighting almost every single day… :(
>
> Honestly, right now, I would very much prefer to just disable it by default.

Before someone says I can disable it, I use new xwiki instances every day.

And on shared instances, I don’t think you can turn it off just for your user ATM.

Thanks
-Vincent

>
> I do lots of testing every day, using velocity and groovy macros and the indentation costs me way too much time than it should, especially for macro closing. In my use cases the coloring is a nice to have but it’s not really needed (I only have a few lines) but the extra keystrokes needed for unindenting are a pain.
>
> Thanks
> -Vincent
>
>>
>> Thanks,
>> Eduard
>>
>> On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <[hidden email]>
>> wrote:
>>
>>> I'm OK with both but I prefer A-2 which is more readable and more logical
>>> IMO.
>>>
>>> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]>
>>> wrote:
>>>> Hi,
>>>>
>>>> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
>>>> Context 2: Fill the “velocity code style” section of
>>> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
>>>>
>>>> Option A-1: No top level indentation
>>>> =========================
>>>>
>>>> {{velocity}}
>>>> #set ($var = …)
>>>> #if (…)
>>>> …
>>>> #if (…)
>>>> #end
>>>> #end
>>>> {{/velocity}}
>>>>
>>>> Nested example:
>>>>
>>>> {{velocity}}
>>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>>>> #set($formname = 'inline')
>>>> #set($saveaction = 'save')
>>>> #set($previewenabled = true)
>>>> #set($xnotification = $!request.getParameter('xnotification'))
>>>> {{html}}
>>>> <form id="inline" method="post" action="$doc.getURL('preview’)">
>>>>   <div>
>>>>   …
>>>> {{/velocity}}
>>>>
>>>> Pros:
>>>> * This is what we currently do which IMO means it’s the more natural way
>>>> * Makes content more visible when editing inside xwiki since it takes
>>> less horizontal space
>>>> * Less typing and less chance to make it wrong
>>>>
>>>> Option A-2: Top level indentation
>>>> ========================
>>>>
>>>> {{velocity}}
>>>> #set ($var = …)
>>>> #if (…)
>>>>   …
>>>>   #if (…)
>>>>   #end
>>>> #end
>>>> {{/velocity}}
>>>>
>>>> Nested example:
>>>>
>>>> {{velocity}}
>>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>>>>   #set($formname = 'inline')
>>>>   #set($saveaction = 'save')
>>>>   #set($previewenabled = true)
>>>>   #set($xnotification = $!request.getParameter('xnotification'))
>>>>   {{html}}
>>>>     <form id="inline" method="post" action="$doc.getURL('preview’)">
>>>>       <div>
>>>>       …
>>>> {{/velocity}}
>>>>
>>>> Pros:
>>>> * More logical since a macro is a container (even though it’s different
>>> syntax - wiki markup vs velocity - so it’s arguable)
>>>> * More legible?
>>>>
>>>> Cons
>>>> * This means slowly changing everywhere we use scripting.
>>>>
>>>> WDYT?
>>>>
>>>> I think my preference goes to A-1 FTM since I’ve never thought to myself
>>> that it was an issue all these years of using it.
>>>>
>>>> Thanks
>>>> -Vincent
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Thomas Mortagne

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Ecaterina Moraru (Valica)
I like and use A-1

I like syntax highlighting and I don't want it disabled by default.

Thanks,
Caty

On Wed, Jun 6, 2018 at 2:25 PM, Vincent Massol <[hidden email]> wrote:

>
>
> > On 6 Jun 2018, at 13:24, Vincent Massol <[hidden email]> wrote:
> >
> >
> >
> >> On 6 Jun 2018, at 12:37, Eduard Moraru <[hidden email]> wrote:
> >>
> >> +1 for A-2, since I find it more consistent and logical for an element
> that
> >> accepts inner content to indent that content, once it spans on multiple
> >> lines (since you can also have the inline version). It would be
> consistent
> >> with the indentation policy we apply for HTML as well.
> >>
> >> I can't find many arguments for making an exception for them, other than
> >> the fact that the velocity and HTML macros tend to be used quite loosely
> >> (i.e. pages with entire content wrapped by a start and end velocity
> macro),
> >> but we are talking generally about all rendering macros, so I think it
> >> makes sense to indent. The SyntaxHighlighting enabled wiki editor also
> >> helps in indenting multiple lines at the same time.
> >>
> >> Note: One thing that I remember that needs fixing in the SH enabled
> editor
> >> is the "decrease indentation" operation (i.e. SHIFT+TAB should decrease
> the
> >> indentation of the selected lines by one level) which is now configured
> to
> >> do "auto-indentation" instead (i.e. indent the lines to the level
> dictated
> >> by the context, a bit similar to the "Auto-Formatting" option in
> Eclipse,
> >> or other IDEs). However, I don't remember hearing many people complain
> >> about this yet, so maybe it's not that painful, but would still need
> fixing.
> >
> > Well on my side I curse the syntax highlighting almost every single day…
> :(
> >
> > Honestly, right now, I would very much prefer to just disable it by
> default.
>
> Before someone says I can disable it, I use new xwiki instances every day.
>
> And on shared instances, I don’t think you can turn it off just for your
> user ATM.
>
> Thanks
> -Vincent
>
> >
> > I do lots of testing every day, using velocity and groovy macros and the
> indentation costs me way too much time than it should, especially for macro
> closing. In my use cases the coloring is a nice to have but it’s not really
> needed (I only have a few lines) but the extra keystrokes needed for
> unindenting are a pain.
> >
> > Thanks
> > -Vincent
> >
> >>
> >> Thanks,
> >> Eduard
> >>
> >> On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <
> [hidden email]>
> >> wrote:
> >>
> >>> I'm OK with both but I prefer A-2 which is more readable and more
> logical
> >>> IMO.
> >>>
> >>> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]>
> >>> wrote:
> >>>> Hi,
> >>>>
> >>>> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> >>>> Context 2: Fill the “velocity code style” section of
> >>> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
> >>>>
> >>>> Option A-1: No top level indentation
> >>>> =========================
> >>>>
> >>>> {{velocity}}
> >>>> #set ($var = …)
> >>>> #if (…)
> >>>> …
> >>>> #if (…)
> >>>> #end
> >>>> #end
> >>>> {{/velocity}}
> >>>>
> >>>> Nested example:
> >>>>
> >>>> {{velocity}}
> >>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> >>>> #set($formname = 'inline')
> >>>> #set($saveaction = 'save')
> >>>> #set($previewenabled = true)
> >>>> #set($xnotification = $!request.getParameter('xnotification'))
> >>>> {{html}}
> >>>> <form id="inline" method="post" action="$doc.getURL('preview’)">
> >>>>   <div>
> >>>>   …
> >>>> {{/velocity}}
> >>>>
> >>>> Pros:
> >>>> * This is what we currently do which IMO means it’s the more natural
> way
> >>>> * Makes content more visible when editing inside xwiki since it takes
> >>> less horizontal space
> >>>> * Less typing and less chance to make it wrong
> >>>>
> >>>> Option A-2: Top level indentation
> >>>> ========================
> >>>>
> >>>> {{velocity}}
> >>>> #set ($var = …)
> >>>> #if (…)
> >>>>   …
> >>>>   #if (…)
> >>>>   #end
> >>>> #end
> >>>> {{/velocity}}
> >>>>
> >>>> Nested example:
> >>>>
> >>>> {{velocity}}
> >>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> >>>>   #set($formname = 'inline')
> >>>>   #set($saveaction = 'save')
> >>>>   #set($previewenabled = true)
> >>>>   #set($xnotification = $!request.getParameter('xnotification'))
> >>>>   {{html}}
> >>>>     <form id="inline" method="post" action="$doc.getURL('preview’)">
> >>>>       <div>
> >>>>       …
> >>>> {{/velocity}}
> >>>>
> >>>> Pros:
> >>>> * More logical since a macro is a container (even though it’s
> different
> >>> syntax - wiki markup vs velocity - so it’s arguable)
> >>>> * More legible?
> >>>>
> >>>> Cons
> >>>> * This means slowly changing everywhere we use scripting.
> >>>>
> >>>> WDYT?
> >>>>
> >>>> I think my preference goes to A-1 FTM since I’ve never thought to
> myself
> >>> that it was an issue all these years of using it.
> >>>>
> >>>> Thanks
> >>>> -Vincent
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>> --
> >>> Thomas Mortagne
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Guillaume Delhumeau
I think just like Caty said.

2018-06-06 13:53 GMT+02:00 Ecaterina Moraru (Valica) <[hidden email]>:

> I like and use A-1
>
> I like syntax highlighting and I don't want it disabled by default.
>
> Thanks,
> Caty
>
> On Wed, Jun 6, 2018 at 2:25 PM, Vincent Massol <[hidden email]> wrote:
>
> >
> >
> > > On 6 Jun 2018, at 13:24, Vincent Massol <[hidden email]> wrote:
> > >
> > >
> > >
> > >> On 6 Jun 2018, at 12:37, Eduard Moraru <[hidden email]> wrote:
> > >>
> > >> +1 for A-2, since I find it more consistent and logical for an element
> > that
> > >> accepts inner content to indent that content, once it spans on
> multiple
> > >> lines (since you can also have the inline version). It would be
> > consistent
> > >> with the indentation policy we apply for HTML as well.
> > >>
> > >> I can't find many arguments for making an exception for them, other
> than
> > >> the fact that the velocity and HTML macros tend to be used quite
> loosely
> > >> (i.e. pages with entire content wrapped by a start and end velocity
> > macro),
> > >> but we are talking generally about all rendering macros, so I think it
> > >> makes sense to indent. The SyntaxHighlighting enabled wiki editor also
> > >> helps in indenting multiple lines at the same time.
> > >>
> > >> Note: One thing that I remember that needs fixing in the SH enabled
> > editor
> > >> is the "decrease indentation" operation (i.e. SHIFT+TAB should
> decrease
> > the
> > >> indentation of the selected lines by one level) which is now
> configured
> > to
> > >> do "auto-indentation" instead (i.e. indent the lines to the level
> > dictated
> > >> by the context, a bit similar to the "Auto-Formatting" option in
> > Eclipse,
> > >> or other IDEs). However, I don't remember hearing many people complain
> > >> about this yet, so maybe it's not that painful, but would still need
> > fixing.
> > >
> > > Well on my side I curse the syntax highlighting almost every single
> day…
> > :(
> > >
> > > Honestly, right now, I would very much prefer to just disable it by
> > default.
> >
> > Before someone says I can disable it, I use new xwiki instances every
> day.
> >
> > And on shared instances, I don’t think you can turn it off just for your
> > user ATM.
> >
> > Thanks
> > -Vincent
> >
> > >
> > > I do lots of testing every day, using velocity and groovy macros and
> the
> > indentation costs me way too much time than it should, especially for
> macro
> > closing. In my use cases the coloring is a nice to have but it’s not
> really
> > needed (I only have a few lines) but the extra keystrokes needed for
> > unindenting are a pain.
> > >
> > > Thanks
> > > -Vincent
> > >
> > >>
> > >> Thanks,
> > >> Eduard
> > >>
> > >> On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <
> > [hidden email]>
> > >> wrote:
> > >>
> > >>> I'm OK with both but I prefer A-2 which is more readable and more
> > logical
> > >>> IMO.
> > >>>
> > >>> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]>
> > >>> wrote:
> > >>>> Hi,
> > >>>>
> > >>>> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> > >>>> Context 2: Fill the “velocity code style” section of
> > >>> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
> > >>>>
> > >>>> Option A-1: No top level indentation
> > >>>> =========================
> > >>>>
> > >>>> {{velocity}}
> > >>>> #set ($var = …)
> > >>>> #if (…)
> > >>>> …
> > >>>> #if (…)
> > >>>> #end
> > >>>> #end
> > >>>> {{/velocity}}
> > >>>>
> > >>>> Nested example:
> > >>>>
> > >>>> {{velocity}}
> > >>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> > >>>> #set($formname = 'inline')
> > >>>> #set($saveaction = 'save')
> > >>>> #set($previewenabled = true)
> > >>>> #set($xnotification = $!request.getParameter('xnotification'))
> > >>>> {{html}}
> > >>>> <form id="inline" method="post" action="$doc.getURL('preview’)">
> > >>>>   <div>
> > >>>>   …
> > >>>> {{/velocity}}
> > >>>>
> > >>>> Pros:
> > >>>> * This is what we currently do which IMO means it’s the more natural
> > way
> > >>>> * Makes content more visible when editing inside xwiki since it
> takes
> > >>> less horizontal space
> > >>>> * Less typing and less chance to make it wrong
> > >>>>
> > >>>> Option A-2: Top level indentation
> > >>>> ========================
> > >>>>
> > >>>> {{velocity}}
> > >>>> #set ($var = …)
> > >>>> #if (…)
> > >>>>   …
> > >>>>   #if (…)
> > >>>>   #end
> > >>>> #end
> > >>>> {{/velocity}}
> > >>>>
> > >>>> Nested example:
> > >>>>
> > >>>> {{velocity}}
> > >>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> > >>>>   #set($formname = 'inline')
> > >>>>   #set($saveaction = 'save')
> > >>>>   #set($previewenabled = true)
> > >>>>   #set($xnotification = $!request.getParameter('xnotification'))
> > >>>>   {{html}}
> > >>>>     <form id="inline" method="post" action="$doc.getURL('preview’)
> ">
> > >>>>       <div>
> > >>>>       …
> > >>>> {{/velocity}}
> > >>>>
> > >>>> Pros:
> > >>>> * More logical since a macro is a container (even though it’s
> > different
> > >>> syntax - wiki markup vs velocity - so it’s arguable)
> > >>>> * More legible?
> > >>>>
> > >>>> Cons
> > >>>> * This means slowly changing everywhere we use scripting.
> > >>>>
> > >>>> WDYT?
> > >>>>
> > >>>> I think my preference goes to A-1 FTM since I’ve never thought to
> > myself
> > >>> that it was an issue all these years of using it.
> > >>>>
> > >>>> Thanks
> > >>>> -Vincent
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>>
> > >>> --
> > >>> Thomas Mortagne
> >
> >
>



--
Guillaume Delhumeau ([hidden email])
Research & Development Engineer at XWiki SAS
Committer on the XWiki.org project
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Alex Cotiugă
In reply to this post by Ecaterina Moraru (Valica)
With minor exceptions, I use A-2 and I would like to get rid of those
exceptions and use only A-2.

Thanks,
Alex

On Wed, Jun 6, 2018 at 2:53 PM, Ecaterina Moraru (Valica) <[hidden email]
> wrote:

> I like and use A-1
>
> I like syntax highlighting and I don't want it disabled by default.
>
> Thanks,
> Caty
>
> On Wed, Jun 6, 2018 at 2:25 PM, Vincent Massol <[hidden email]> wrote:
>
> >
> >
> > > On 6 Jun 2018, at 13:24, Vincent Massol <[hidden email]> wrote:
> > >
> > >
> > >
> > >> On 6 Jun 2018, at 12:37, Eduard Moraru <[hidden email]> wrote:
> > >>
> > >> +1 for A-2, since I find it more consistent and logical for an element
> > that
> > >> accepts inner content to indent that content, once it spans on
> multiple
> > >> lines (since you can also have the inline version). It would be
> > consistent
> > >> with the indentation policy we apply for HTML as well.
> > >>
> > >> I can't find many arguments for making an exception for them, other
> than
> > >> the fact that the velocity and HTML macros tend to be used quite
> loosely
> > >> (i.e. pages with entire content wrapped by a start and end velocity
> > macro),
> > >> but we are talking generally about all rendering macros, so I think it
> > >> makes sense to indent. The SyntaxHighlighting enabled wiki editor also
> > >> helps in indenting multiple lines at the same time.
> > >>
> > >> Note: One thing that I remember that needs fixing in the SH enabled
> > editor
> > >> is the "decrease indentation" operation (i.e. SHIFT+TAB should
> decrease
> > the
> > >> indentation of the selected lines by one level) which is now
> configured
> > to
> > >> do "auto-indentation" instead (i.e. indent the lines to the level
> > dictated
> > >> by the context, a bit similar to the "Auto-Formatting" option in
> > Eclipse,
> > >> or other IDEs). However, I don't remember hearing many people complain
> > >> about this yet, so maybe it's not that painful, but would still need
> > fixing.
> > >
> > > Well on my side I curse the syntax highlighting almost every single
> day…
> > :(
> > >
> > > Honestly, right now, I would very much prefer to just disable it by
> > default.
> >
> > Before someone says I can disable it, I use new xwiki instances every
> day.
> >
> > And on shared instances, I don’t think you can turn it off just for your
> > user ATM.
> >
> > Thanks
> > -Vincent
> >
> > >
> > > I do lots of testing every day, using velocity and groovy macros and
> the
> > indentation costs me way too much time than it should, especially for
> macro
> > closing. In my use cases the coloring is a nice to have but it’s not
> really
> > needed (I only have a few lines) but the extra keystrokes needed for
> > unindenting are a pain.
> > >
> > > Thanks
> > > -Vincent
> > >
> > >>
> > >> Thanks,
> > >> Eduard
> > >>
> > >> On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <
> > [hidden email]>
> > >> wrote:
> > >>
> > >>> I'm OK with both but I prefer A-2 which is more readable and more
> > logical
> > >>> IMO.
> > >>>
> > >>> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]>
> > >>> wrote:
> > >>>> Hi,
> > >>>>
> > >>>> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> > >>>> Context 2: Fill the “velocity code style” section of
> > >>> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
> > >>>>
> > >>>> Option A-1: No top level indentation
> > >>>> =========================
> > >>>>
> > >>>> {{velocity}}
> > >>>> #set ($var = …)
> > >>>> #if (…)
> > >>>> …
> > >>>> #if (…)
> > >>>> #end
> > >>>> #end
> > >>>> {{/velocity}}
> > >>>>
> > >>>> Nested example:
> > >>>>
> > >>>> {{velocity}}
> > >>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> > >>>> #set($formname = 'inline')
> > >>>> #set($saveaction = 'save')
> > >>>> #set($previewenabled = true)
> > >>>> #set($xnotification = $!request.getParameter('xnotification'))
> > >>>> {{html}}
> > >>>> <form id="inline" method="post" action="$doc.getURL('preview’)">
> > >>>>   <div>
> > >>>>   …
> > >>>> {{/velocity}}
> > >>>>
> > >>>> Pros:
> > >>>> * This is what we currently do which IMO means it’s the more natural
> > way
> > >>>> * Makes content more visible when editing inside xwiki since it
> takes
> > >>> less horizontal space
> > >>>> * Less typing and less chance to make it wrong
> > >>>>
> > >>>> Option A-2: Top level indentation
> > >>>> ========================
> > >>>>
> > >>>> {{velocity}}
> > >>>> #set ($var = …)
> > >>>> #if (…)
> > >>>>   …
> > >>>>   #if (…)
> > >>>>   #end
> > >>>> #end
> > >>>> {{/velocity}}
> > >>>>
> > >>>> Nested example:
> > >>>>
> > >>>> {{velocity}}
> > >>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> > >>>>   #set($formname = 'inline')
> > >>>>   #set($saveaction = 'save')
> > >>>>   #set($previewenabled = true)
> > >>>>   #set($xnotification = $!request.getParameter('xnotification'))
> > >>>>   {{html}}
> > >>>>     <form id="inline" method="post" action="$doc.getURL('preview’)
> ">
> > >>>>       <div>
> > >>>>       …
> > >>>> {{/velocity}}
> > >>>>
> > >>>> Pros:
> > >>>> * More logical since a macro is a container (even though it’s
> > different
> > >>> syntax - wiki markup vs velocity - so it’s arguable)
> > >>>> * More legible?
> > >>>>
> > >>>> Cons
> > >>>> * This means slowly changing everywhere we use scripting.
> > >>>>
> > >>>> WDYT?
> > >>>>
> > >>>> I think my preference goes to A-1 FTM since I’ve never thought to
> > myself
> > >>> that it was an issue all these years of using it.
> > >>>>
> > >>>> Thanks
> > >>>> -Vincent
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>>
> > >>> --
> > >>> Thomas Mortagne
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

vmassol
Administrator
Hi Alex,

> On 6 Jun 2018, at 13:57, Alex Cotiugă <[hidden email]> wrote:
>
> With minor exceptions, I use A-2 and I would like to get rid of those
> exceptions and use only A-2.

Could you explain what you have in mind by “minor exceptions”?

AFAIK you use A-1 and not A-2 since I don’t think we have any committed code using A-2 ATM (I could be wrong).

Maybe you meant A-1?

Thanks
-Vincent

>
> Thanks,
> Alex
>
> On Wed, Jun 6, 2018 at 2:53 PM, Ecaterina Moraru (Valica) <[hidden email]
>> wrote:
>
>> I like and use A-1
>>
>> I like syntax highlighting and I don't want it disabled by default.
>>
>> Thanks,
>> Caty
>>
>> On Wed, Jun 6, 2018 at 2:25 PM, Vincent Massol <[hidden email]> wrote:
>>
>>>
>>>
>>>> On 6 Jun 2018, at 13:24, Vincent Massol <[hidden email]> wrote:
>>>>
>>>>
>>>>
>>>>> On 6 Jun 2018, at 12:37, Eduard Moraru <[hidden email]> wrote:
>>>>>
>>>>> +1 for A-2, since I find it more consistent and logical for an element
>>> that
>>>>> accepts inner content to indent that content, once it spans on
>> multiple
>>>>> lines (since you can also have the inline version). It would be
>>> consistent
>>>>> with the indentation policy we apply for HTML as well.
>>>>>
>>>>> I can't find many arguments for making an exception for them, other
>> than
>>>>> the fact that the velocity and HTML macros tend to be used quite
>> loosely
>>>>> (i.e. pages with entire content wrapped by a start and end velocity
>>> macro),
>>>>> but we are talking generally about all rendering macros, so I think it
>>>>> makes sense to indent. The SyntaxHighlighting enabled wiki editor also
>>>>> helps in indenting multiple lines at the same time.
>>>>>
>>>>> Note: One thing that I remember that needs fixing in the SH enabled
>>> editor
>>>>> is the "decrease indentation" operation (i.e. SHIFT+TAB should
>> decrease
>>> the
>>>>> indentation of the selected lines by one level) which is now
>> configured
>>> to
>>>>> do "auto-indentation" instead (i.e. indent the lines to the level
>>> dictated
>>>>> by the context, a bit similar to the "Auto-Formatting" option in
>>> Eclipse,
>>>>> or other IDEs). However, I don't remember hearing many people complain
>>>>> about this yet, so maybe it's not that painful, but would still need
>>> fixing.
>>>>
>>>> Well on my side I curse the syntax highlighting almost every single
>> day…
>>> :(
>>>>
>>>> Honestly, right now, I would very much prefer to just disable it by
>>> default.
>>>
>>> Before someone says I can disable it, I use new xwiki instances every
>> day.
>>>
>>> And on shared instances, I don’t think you can turn it off just for your
>>> user ATM.
>>>
>>> Thanks
>>> -Vincent
>>>
>>>>
>>>> I do lots of testing every day, using velocity and groovy macros and
>> the
>>> indentation costs me way too much time than it should, especially for
>> macro
>>> closing. In my use cases the coloring is a nice to have but it’s not
>> really
>>> needed (I only have a few lines) but the extra keystrokes needed for
>>> unindenting are a pain.
>>>>
>>>> Thanks
>>>> -Vincent
>>>>
>>>>>
>>>>> Thanks,
>>>>> Eduard
>>>>>
>>>>> On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <
>>> [hidden email]>
>>>>> wrote:
>>>>>
>>>>>> I'm OK with both but I prefer A-2 which is more readable and more
>>> logical
>>>>>> IMO.
>>>>>>
>>>>>> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]>
>>>>>> wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
>>>>>>> Context 2: Fill the “velocity code style” section of
>>>>>> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
>>>>>>>
>>>>>>> Option A-1: No top level indentation
>>>>>>> =========================
>>>>>>>
>>>>>>> {{velocity}}
>>>>>>> #set ($var = …)
>>>>>>> #if (…)
>>>>>>> …
>>>>>>> #if (…)
>>>>>>> #end
>>>>>>> #end
>>>>>>> {{/velocity}}
>>>>>>>
>>>>>>> Nested example:
>>>>>>>
>>>>>>> {{velocity}}
>>>>>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>>>>>>> #set($formname = 'inline')
>>>>>>> #set($saveaction = 'save')
>>>>>>> #set($previewenabled = true)
>>>>>>> #set($xnotification = $!request.getParameter('xnotification'))
>>>>>>> {{html}}
>>>>>>> <form id="inline" method="post" action="$doc.getURL('preview’)">
>>>>>>>  <div>
>>>>>>>  …
>>>>>>> {{/velocity}}
>>>>>>>
>>>>>>> Pros:
>>>>>>> * This is what we currently do which IMO means it’s the more natural
>>> way
>>>>>>> * Makes content more visible when editing inside xwiki since it
>> takes
>>>>>> less horizontal space
>>>>>>> * Less typing and less chance to make it wrong
>>>>>>>
>>>>>>> Option A-2: Top level indentation
>>>>>>> ========================
>>>>>>>
>>>>>>> {{velocity}}
>>>>>>> #set ($var = …)
>>>>>>> #if (…)
>>>>>>>  …
>>>>>>>  #if (…)
>>>>>>>  #end
>>>>>>> #end
>>>>>>> {{/velocity}}
>>>>>>>
>>>>>>> Nested example:
>>>>>>>
>>>>>>> {{velocity}}
>>>>>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>>>>>>>  #set($formname = 'inline')
>>>>>>>  #set($saveaction = 'save')
>>>>>>>  #set($previewenabled = true)
>>>>>>>  #set($xnotification = $!request.getParameter('xnotification'))
>>>>>>>  {{html}}
>>>>>>>    <form id="inline" method="post" action="$doc.getURL('preview’)
>> ">
>>>>>>>      <div>
>>>>>>>      …
>>>>>>> {{/velocity}}
>>>>>>>
>>>>>>> Pros:
>>>>>>> * More logical since a macro is a container (even though it’s
>>> different
>>>>>> syntax - wiki markup vs velocity - so it’s arguable)
>>>>>>> * More legible?
>>>>>>>
>>>>>>> Cons
>>>>>>> * This means slowly changing everywhere we use scripting.
>>>>>>>
>>>>>>> WDYT?
>>>>>>>
>>>>>>> I think my preference goes to A-1 FTM since I’ve never thought to
>>> myself
>>>>>> that it was an issue all these years of using it.
>>>>>>>
>>>>>>> Thanks
>>>>>>> -Vincent
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Thomas Mortagne
>>>
>>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Alex Cotiugă
My exception is in indenting just after {{velocity}}, which I don't do, but
for other macros {{html}}, {{info}}. Here's an example:
{{velocity}}
#macro (displayProperty $propertyName)
  {{html clean="false"}}
    <div class="row">
      #if ($xcontext.action == 'edit')
        $doc.getValue($propertyName)
      #end
    </div>
  {{/html}}
#end
{{/velocity}}


On Wed, Jun 6, 2018 at 3:02 PM, Vincent Massol <[hidden email]> wrote:

> Hi Alex,
>
> > On 6 Jun 2018, at 13:57, Alex Cotiugă <[hidden email]>
> wrote:
> >
> > With minor exceptions, I use A-2 and I would like to get rid of those
> > exceptions and use only A-2.
>
> Could you explain what you have in mind by “minor exceptions”?
>
> AFAIK you use A-1 and not A-2 since I don’t think we have any committed
> code using A-2 ATM (I could be wrong).
>
> Maybe you meant A-1?
>
> Thanks
> -Vincent
>
> >
> > Thanks,
> > Alex
> >
> > On Wed, Jun 6, 2018 at 2:53 PM, Ecaterina Moraru (Valica) <
> [hidden email]
> >> wrote:
> >
> >> I like and use A-1
> >>
> >> I like syntax highlighting and I don't want it disabled by default.
> >>
> >> Thanks,
> >> Caty
> >>
> >> On Wed, Jun 6, 2018 at 2:25 PM, Vincent Massol <[hidden email]>
> wrote:
> >>
> >>>
> >>>
> >>>> On 6 Jun 2018, at 13:24, Vincent Massol <[hidden email]> wrote:
> >>>>
> >>>>
> >>>>
> >>>>> On 6 Jun 2018, at 12:37, Eduard Moraru <[hidden email]> wrote:
> >>>>>
> >>>>> +1 for A-2, since I find it more consistent and logical for an
> element
> >>> that
> >>>>> accepts inner content to indent that content, once it spans on
> >> multiple
> >>>>> lines (since you can also have the inline version). It would be
> >>> consistent
> >>>>> with the indentation policy we apply for HTML as well.
> >>>>>
> >>>>> I can't find many arguments for making an exception for them, other
> >> than
> >>>>> the fact that the velocity and HTML macros tend to be used quite
> >> loosely
> >>>>> (i.e. pages with entire content wrapped by a start and end velocity
> >>> macro),
> >>>>> but we are talking generally about all rendering macros, so I think
> it
> >>>>> makes sense to indent. The SyntaxHighlighting enabled wiki editor
> also
> >>>>> helps in indenting multiple lines at the same time.
> >>>>>
> >>>>> Note: One thing that I remember that needs fixing in the SH enabled
> >>> editor
> >>>>> is the "decrease indentation" operation (i.e. SHIFT+TAB should
> >> decrease
> >>> the
> >>>>> indentation of the selected lines by one level) which is now
> >> configured
> >>> to
> >>>>> do "auto-indentation" instead (i.e. indent the lines to the level
> >>> dictated
> >>>>> by the context, a bit similar to the "Auto-Formatting" option in
> >>> Eclipse,
> >>>>> or other IDEs). However, I don't remember hearing many people
> complain
> >>>>> about this yet, so maybe it's not that painful, but would still need
> >>> fixing.
> >>>>
> >>>> Well on my side I curse the syntax highlighting almost every single
> >> day…
> >>> :(
> >>>>
> >>>> Honestly, right now, I would very much prefer to just disable it by
> >>> default.
> >>>
> >>> Before someone says I can disable it, I use new xwiki instances every
> >> day.
> >>>
> >>> And on shared instances, I don’t think you can turn it off just for
> your
> >>> user ATM.
> >>>
> >>> Thanks
> >>> -Vincent
> >>>
> >>>>
> >>>> I do lots of testing every day, using velocity and groovy macros and
> >> the
> >>> indentation costs me way too much time than it should, especially for
> >> macro
> >>> closing. In my use cases the coloring is a nice to have but it’s not
> >> really
> >>> needed (I only have a few lines) but the extra keystrokes needed for
> >>> unindenting are a pain.
> >>>>
> >>>> Thanks
> >>>> -Vincent
> >>>>
> >>>>>
> >>>>> Thanks,
> >>>>> Eduard
> >>>>>
> >>>>> On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <
> >>> [hidden email]>
> >>>>> wrote:
> >>>>>
> >>>>>> I'm OK with both but I prefer A-2 which is more readable and more
> >>> logical
> >>>>>> IMO.
> >>>>>>
> >>>>>> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]
> >
> >>>>>> wrote:
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> >>>>>>> Context 2: Fill the “velocity code style” section of
> >>>>>> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
> >>>>>>>
> >>>>>>> Option A-1: No top level indentation
> >>>>>>> =========================
> >>>>>>>
> >>>>>>> {{velocity}}
> >>>>>>> #set ($var = …)
> >>>>>>> #if (…)
> >>>>>>> …
> >>>>>>> #if (…)
> >>>>>>> #end
> >>>>>>> #end
> >>>>>>> {{/velocity}}
> >>>>>>>
> >>>>>>> Nested example:
> >>>>>>>
> >>>>>>> {{velocity}}
> >>>>>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> >>>>>>> #set($formname = 'inline')
> >>>>>>> #set($saveaction = 'save')
> >>>>>>> #set($previewenabled = true)
> >>>>>>> #set($xnotification = $!request.getParameter('xnotification'))
> >>>>>>> {{html}}
> >>>>>>> <form id="inline" method="post" action="$doc.getURL('preview’)">
> >>>>>>>  <div>
> >>>>>>>  …
> >>>>>>> {{/velocity}}
> >>>>>>>
> >>>>>>> Pros:
> >>>>>>> * This is what we currently do which IMO means it’s the more
> natural
> >>> way
> >>>>>>> * Makes content more visible when editing inside xwiki since it
> >> takes
> >>>>>> less horizontal space
> >>>>>>> * Less typing and less chance to make it wrong
> >>>>>>>
> >>>>>>> Option A-2: Top level indentation
> >>>>>>> ========================
> >>>>>>>
> >>>>>>> {{velocity}}
> >>>>>>> #set ($var = …)
> >>>>>>> #if (…)
> >>>>>>>  …
> >>>>>>>  #if (…)
> >>>>>>>  #end
> >>>>>>> #end
> >>>>>>> {{/velocity}}
> >>>>>>>
> >>>>>>> Nested example:
> >>>>>>>
> >>>>>>> {{velocity}}
> >>>>>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> >>>>>>>  #set($formname = 'inline')
> >>>>>>>  #set($saveaction = 'save')
> >>>>>>>  #set($previewenabled = true)
> >>>>>>>  #set($xnotification = $!request.getParameter('xnotification'))
> >>>>>>>  {{html}}
> >>>>>>>    <form id="inline" method="post" action="$doc.getURL('preview’)
> >> ">
> >>>>>>>      <div>
> >>>>>>>      …
> >>>>>>> {{/velocity}}
> >>>>>>>
> >>>>>>> Pros:
> >>>>>>> * More logical since a macro is a container (even though it’s
> >>> different
> >>>>>> syntax - wiki markup vs velocity - so it’s arguable)
> >>>>>>> * More legible?
> >>>>>>>
> >>>>>>> Cons
> >>>>>>> * This means slowly changing everywhere we use scripting.
> >>>>>>>
> >>>>>>> WDYT?
> >>>>>>>
> >>>>>>> I think my preference goes to A-1 FTM since I’ve never thought to
> >>> myself
> >>>>>> that it was an issue all these years of using it.
> >>>>>>>
> >>>>>>> Thanks
> >>>>>>> -Vincent
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> --
> >>>>>> Thomas Mortagne
> >>>
> >>>
> >>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

vmassol
Administrator


> On 6 Jun 2018, at 14:09, Alex Cotiugă <[hidden email]> wrote:
>
> My exception is in indenting just after {{velocity}}, which I don't do, but
> for other macros {{html}}, {{info}}. Here's an example:
> {{velocity}}
> #macro (displayProperty $propertyName)
>  {{html clean="false"}}
>    <div class="row">
>      #if ($xcontext.action == 'edit')
>        $doc.getValue($propertyName)
>      #end
>    </div>
>  {{/html}}
> #end
> {{/velocity}}

Ok so this example is A-1 actually ;)

With a small variation for nested. And indeed for this variation I also usually do what you pasted too but not always. We’ll need to discuss this variation I agree, but first let’s select what we want for the top elements.

If you have only a single top level {{html}} macro do you write:

{{html}}
<div>…
{{/html}}

or

{{html}}
  <div>….
{{/html}}

?

So to confirm what you’d prefer is the second one, i.e. A-2 for all rendering macros located at the top level right?

Thanks
-Vincent

>
>
> On Wed, Jun 6, 2018 at 3:02 PM, Vincent Massol <[hidden email]> wrote:
>
>> Hi Alex,
>>
>>> On 6 Jun 2018, at 13:57, Alex Cotiugă <[hidden email]>
>> wrote:
>>>
>>> With minor exceptions, I use A-2 and I would like to get rid of those
>>> exceptions and use only A-2.
>>
>> Could you explain what you have in mind by “minor exceptions”?
>>
>> AFAIK you use A-1 and not A-2 since I don’t think we have any committed
>> code using A-2 ATM (I could be wrong).
>>
>> Maybe you meant A-1?
>>
>> Thanks
>> -Vincent
>>
>>>
>>> Thanks,
>>> Alex
>>>
>>> On Wed, Jun 6, 2018 at 2:53 PM, Ecaterina Moraru (Valica) <
>> [hidden email]
>>>> wrote:
>>>
>>>> I like and use A-1
>>>>
>>>> I like syntax highlighting and I don't want it disabled by default.
>>>>
>>>> Thanks,
>>>> Caty
>>>>
>>>> On Wed, Jun 6, 2018 at 2:25 PM, Vincent Massol <[hidden email]>
>> wrote:
>>>>
>>>>>
>>>>>
>>>>>> On 6 Jun 2018, at 13:24, Vincent Massol <[hidden email]> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> On 6 Jun 2018, at 12:37, Eduard Moraru <[hidden email]> wrote:
>>>>>>>
>>>>>>> +1 for A-2, since I find it more consistent and logical for an
>> element
>>>>> that
>>>>>>> accepts inner content to indent that content, once it spans on
>>>> multiple
>>>>>>> lines (since you can also have the inline version). It would be
>>>>> consistent
>>>>>>> with the indentation policy we apply for HTML as well.
>>>>>>>
>>>>>>> I can't find many arguments for making an exception for them, other
>>>> than
>>>>>>> the fact that the velocity and HTML macros tend to be used quite
>>>> loosely
>>>>>>> (i.e. pages with entire content wrapped by a start and end velocity
>>>>> macro),
>>>>>>> but we are talking generally about all rendering macros, so I think
>> it
>>>>>>> makes sense to indent. The SyntaxHighlighting enabled wiki editor
>> also
>>>>>>> helps in indenting multiple lines at the same time.
>>>>>>>
>>>>>>> Note: One thing that I remember that needs fixing in the SH enabled
>>>>> editor
>>>>>>> is the "decrease indentation" operation (i.e. SHIFT+TAB should
>>>> decrease
>>>>> the
>>>>>>> indentation of the selected lines by one level) which is now
>>>> configured
>>>>> to
>>>>>>> do "auto-indentation" instead (i.e. indent the lines to the level
>>>>> dictated
>>>>>>> by the context, a bit similar to the "Auto-Formatting" option in
>>>>> Eclipse,
>>>>>>> or other IDEs). However, I don't remember hearing many people
>> complain
>>>>>>> about this yet, so maybe it's not that painful, but would still need
>>>>> fixing.
>>>>>>
>>>>>> Well on my side I curse the syntax highlighting almost every single
>>>> day…
>>>>> :(
>>>>>>
>>>>>> Honestly, right now, I would very much prefer to just disable it by
>>>>> default.
>>>>>
>>>>> Before someone says I can disable it, I use new xwiki instances every
>>>> day.
>>>>>
>>>>> And on shared instances, I don’t think you can turn it off just for
>> your
>>>>> user ATM.
>>>>>
>>>>> Thanks
>>>>> -Vincent
>>>>>
>>>>>>
>>>>>> I do lots of testing every day, using velocity and groovy macros and
>>>> the
>>>>> indentation costs me way too much time than it should, especially for
>>>> macro
>>>>> closing. In my use cases the coloring is a nice to have but it’s not
>>>> really
>>>>> needed (I only have a few lines) but the extra keystrokes needed for
>>>>> unindenting are a pain.
>>>>>>
>>>>>> Thanks
>>>>>> -Vincent
>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Eduard
>>>>>>>
>>>>>>> On Wed, Jun 6, 2018 at 12:59 PM, Thomas Mortagne <
>>>>> [hidden email]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> I'm OK with both but I prefer A-2 which is more readable and more
>>>>> logical
>>>>>>>> IMO.
>>>>>>>>
>>>>>>>> On Wed, Jun 6, 2018 at 11:49 AM, Vincent Massol <[hidden email]
>>>
>>>>>>>> wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
>>>>>>>>> Context 2: Fill the “velocity code style” section of
>>>>>>>> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
>>>>>>>>>
>>>>>>>>> Option A-1: No top level indentation
>>>>>>>>> =========================
>>>>>>>>>
>>>>>>>>> {{velocity}}
>>>>>>>>> #set ($var = …)
>>>>>>>>> #if (…)
>>>>>>>>> …
>>>>>>>>> #if (…)
>>>>>>>>> #end
>>>>>>>>> #end
>>>>>>>>> {{/velocity}}
>>>>>>>>>
>>>>>>>>> Nested example:
>>>>>>>>>
>>>>>>>>> {{velocity}}
>>>>>>>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>>>>>>>>> #set($formname = 'inline')
>>>>>>>>> #set($saveaction = 'save')
>>>>>>>>> #set($previewenabled = true)
>>>>>>>>> #set($xnotification = $!request.getParameter('xnotification'))
>>>>>>>>> {{html}}
>>>>>>>>> <form id="inline" method="post" action="$doc.getURL('preview’)">
>>>>>>>>> <div>
>>>>>>>>> …
>>>>>>>>> {{/velocity}}
>>>>>>>>>
>>>>>>>>> Pros:
>>>>>>>>> * This is what we currently do which IMO means it’s the more
>> natural
>>>>> way
>>>>>>>>> * Makes content more visible when editing inside xwiki since it
>>>> takes
>>>>>>>> less horizontal space
>>>>>>>>> * Less typing and less chance to make it wrong
>>>>>>>>>
>>>>>>>>> Option A-2: Top level indentation
>>>>>>>>> ========================
>>>>>>>>>
>>>>>>>>> {{velocity}}
>>>>>>>>> #set ($var = …)
>>>>>>>>> #if (…)
>>>>>>>>> …
>>>>>>>>> #if (…)
>>>>>>>>> #end
>>>>>>>>> #end
>>>>>>>>> {{/velocity}}
>>>>>>>>>
>>>>>>>>> Nested example:
>>>>>>>>>
>>>>>>>>> {{velocity}}
>>>>>>>>> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>>>>>>>>> #set($formname = 'inline')
>>>>>>>>> #set($saveaction = 'save')
>>>>>>>>> #set($previewenabled = true)
>>>>>>>>> #set($xnotification = $!request.getParameter('xnotification'))
>>>>>>>>> {{html}}
>>>>>>>>>   <form id="inline" method="post" action="$doc.getURL('preview’)
>>>> ">
>>>>>>>>>     <div>
>>>>>>>>>     …
>>>>>>>>> {{/velocity}}
>>>>>>>>>
>>>>>>>>> Pros:
>>>>>>>>> * More logical since a macro is a container (even though it’s
>>>>> different
>>>>>>>> syntax - wiki markup vs velocity - so it’s arguable)
>>>>>>>>> * More legible?
>>>>>>>>>
>>>>>>>>> Cons
>>>>>>>>> * This means slowly changing everywhere we use scripting.
>>>>>>>>>
>>>>>>>>> WDYT?
>>>>>>>>>
>>>>>>>>> I think my preference goes to A-1 FTM since I’ve never thought to
>>>>> myself
>>>>>>>> that it was an issue all these years of using it.
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>> -Vincent
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Thomas Mortagne
>>>>>
>>>>>
>>>>
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Marius Dumitru Florea
In reply to this post by vmassol
I've always used A-1 and I'd like to keep it that way.

Thanks,
Marius

On Wed, Jun 6, 2018 at 12:49 PM, Vincent Massol <[hidden email]> wrote:

> Hi,
>
> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> Context 2: Fill the “velocity code style” section of
> http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
>
> Option A-1: No top level indentation
> =========================
>
> {{velocity}}
> #set ($var = …)
> #if (…)
>   …
>   #if (…)
>   #end
> #end
> {{/velocity}}
>
> Nested example:
>
> {{velocity}}
> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>   #set($formname = 'inline')
>   #set($saveaction = 'save')
>   #set($previewenabled = true)
>   #set($xnotification = $!request.getParameter('xnotification'))
>   {{html}}
>   <form id="inline" method="post" action="$doc.getURL('preview’)">
>     <div>
>     …
> {{/velocity}}
>
> Pros:
> * This is what we currently do which IMO means it’s the more natural way
> * Makes content more visible when editing inside xwiki since it takes less
> horizontal space
> * Less typing and less chance to make it wrong
>
> Option A-2: Top level indentation
> ========================
>
> {{velocity}}
>   #set ($var = …)
>   #if (…)
>     …
>     #if (…)
>     #end
>   #end
> {{/velocity}}
>
> Nested example:
>
> {{velocity}}
>   #if ($doc.fullName != 'XWiki.AdminInlineSheet')
>     #set($formname = 'inline')
>     #set($saveaction = 'save')
>     #set($previewenabled = true)
>     #set($xnotification = $!request.getParameter('xnotification'))
>     {{html}}
>       <form id="inline" method="post" action="$doc.getURL('preview’)">
>         <div>
>         …
> {{/velocity}}
>
> Pros:
> * More logical since a macro is a container (even though it’s different
> syntax - wiki markup vs velocity - so it’s arguable)
> * More legible?
>
> Cons
> * This means slowly changing everywhere we use scripting.
>
> WDYT?
>
> I think my preference goes to A-1 FTM since I’ve never thought to myself
> that it was an issue all these years of using it.
>
> Thanks
> -Vincent
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] Best practices on indentation for rendering macros in scripts

Denis Gervalle-2
In reply to this post by vmassol
Hi,

Not a matter of preference for me, since not all macro contents afford being indended, A-1 is the most natural option IMO.
Regards,

--
Denis Gervalle

On 6 Jun 2018, 11:49 +0200, Vincent Massol <[hidden email]>, wrote:

> Hi,
>
> Context 1: https://jira.xwiki.org/browse/WIKIEDITOR-58
> Context 2: Fill the “velocity code style” section of http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle/
>
> Option A-1: No top level indentation
> =========================
>
> {{velocity}}
> #set ($var = …)
> #if (…)
> …
> #if (…)
> #end
> #end
> {{/velocity}}
>
> Nested example:
>
> {{velocity}}
> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> #set($formname = 'inline')
> #set($saveaction = 'save')
> #set($previewenabled = true)
> #set($xnotification = $!request.getParameter('xnotification'))
> {{html}}
> <form id="inline" method="post" action="$doc.getURL('preview’)">
> <div>
> …
> {{/velocity}}
>
> Pros:
> * This is what we currently do which IMO means it’s the more natural way
> * Makes content more visible when editing inside xwiki since it takes less horizontal space
> * Less typing and less chance to make it wrong
>
> Option A-2: Top level indentation
> ========================
>
> {{velocity}}
> #set ($var = …)
> #if (…)
> …
> #if (…)
> #end
> #end
> {{/velocity}}
>
> Nested example:
>
> {{velocity}}
> #if ($doc.fullName != 'XWiki.AdminInlineSheet')
> #set($formname = 'inline')
> #set($saveaction = 'save')
> #set($previewenabled = true)
> #set($xnotification = $!request.getParameter('xnotification'))
> {{html}}
> <form id="inline" method="post" action="$doc.getURL('preview’)">
> <div>
> …
> {{/velocity}}
>
> Pros:
> * More logical since a macro is a container (even though it’s different syntax - wiki markup vs velocity - so it’s arguable)
> * More legible?
>
> Cons
> * This means slowly changing everywhere we use scripting.
>
> WDYT?
>
> I think my preference goes to A-1 FTM since I’ve never thought to myself that it was an issue all these years of using it.
>
> Thanks
> -Vincent
>
>