Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Apache Velocity language #280

Closed
rediris opened this issue Feb 26, 2016 · 4 comments
Closed

Add support for Apache Velocity language #280

rediris opened this issue Feb 26, 2016 · 4 comments

Comments

@rediris
Copy link

rediris commented Feb 26, 2016

Atom Beautify could not determine a supported beautifier to handle this file with grammar "Velocity (HTML)" and extension "vtl" or "vm". If you would like to request support for this file and its language, please create an issue for Atom Beautify at https://github.com/Glavin001/atom-beautify/issues.

I have already opened an issue in Atom Beautify: Glavin001/atom-beautify#522

Velocity reference guide

I have tried running this through http://prettydiff.com/?m=beautify

While there wasn't a specific selection for Velocity in prettydiff, it seemed to work... somewhat using with markup (non-specific), force indent, and preserve white space in text. Without those settings enabled, it seems to take the # used in velocity and attempt to put it all on the same line. It still needs some additional work for velocity, it seems.

Here's the original sample I submitted:

## THIS IS A VELOCITY SINGLE-LINE COMMENT

#if($this)
  #set($that = true)
#end

#* 
 THIS IS A VELOCITY COMMENT BLOCK
 LET'S SEE WHAT HAPPENS
*#

#foreach( $item in $list )
  <article>
    <h1>$item.title</h1>
    <p>$item.copy</p>
    <a href="$item.url" class="$item.class">$item.buttonText</a>
  </article>
#end

The results using markup (non-specific) only:

## THIS IS A VELOCITY SINGLE-LINE COMMENT #if($this) #set($that = true) #end #*
THIS IS A VELOCITY COMMENT BLOCK LET'S SEE WHAT HAPPENS *# #foreach( $item in
$list )
<article>
    <h1>
        $item.title
    </h1>
    <p>
        $item.copy
    </p>
    <a class="$item.class" href="$item.url">
        $item.buttonText
    </a>
</article>

Obviously, that is hardly what I started with.

Here's the same example with force indent and preserve white space:

## THIS IS A VELOCITY SINGLE-LINE COMMENT

#if($this)
  #set($that = true)
#end

#* 
 THIS IS A VELOCITY COMMENT BLOCK
 LET'S SEE WHAT HAPPENS
*#

#foreach($item in $list)

<article>
    <h1>$item.title
    </h1>
    <p>$item.copy
    </p>
    <a class="$item.class" href="$item.url">$item.buttonText
    </a>
</article>

It's still missing the closing #end in the #foreach, unfortunately.

@prettydiff
Copy link
Owner

I am thinking that # is far to generic to identify as a tag delimiter apart from normal text content. To be safe I will likely hide Velocity support behind an option so that I can mandate these conventions without regression fear.

@rediris
Copy link
Author

rediris commented Feb 26, 2016

Sure, makes sense.

@prettydiff
Copy link
Owner

Notes:

Tags delimited as follows:

  • #word ... end of line - logic or command
  • $word ... end of line - variable
  • $!word ... end of line - silent variable
  • ${word} ... end of line - formal variable
  • $!{word} ... end of line - formal silent variable
  • #* ... *# - block comment
  • ... end of line - single line comment

  • #[[ ... ]]# - block comment (cdata expression)
  • #(space) will be treated as regular unparsed text content
  • #if and #foreach will be template_start types
  • #end will be template_end type
  • #else and #elseif will be template_else types

@prettydiff
Copy link
Owner

Support is added to branch 2.1.0 and will be published to master soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants