Is it possible to format html in a multi-line string? E.g. in an AngularJS 2 template.
Answered
For example the angular tutorial has the following code in a multi-line comment (declared with ` )
template:`
<h1>{{title}}</h1>
<h2>{{hero.name}} details!</h2>
<div><label>id: </label>{{hero.id}}</div>
<div>
<label>name: </label>
<input [(ngModel)]="hero.name" placeholder="name">
</div>
`
None of the code styles I've looked at seem to have a way to format the html within the multi-line comment. Is there a way to do this (other than manually) - or at least specifically with Angular components?
Thanks!
Please sign in to leave a comment.
Hi,
You can place the cared inside of the HTML code, press Alt+Enter and select "Edit HTML fragment", then apply code format in opened HTML fragment - it will be propagated to the original file.
Thanks for your response. That sort of works, and reformatting the html fragment looks nice, but it still leaves in unformatted in the actual file, eg: http://imgur.com/ZJzr1n3
I'm trying to get a formatting similar to this: http://plnkr.co/edit/?p=preview
Thanks!
Unfortunately, there's no straight way to do this at the moment. You can try to manually set the line breaks and enable "Keep line breaks" in File | Settings (PhpStorm | Preferences for Mac) | Editor | Code Style | HTML > Other.
We already have a related request submitted to our tracker here: <https://youtrack.jetbrains.com/issue/WEB-18226>. Please vote for it in order to move it up in the queue and receive notifications regarding the progress of the feature. See more information on working with tracker at <https://intellij-support.jetbrains.com/entries/23368682>.
Thanks! I've gone ahead and done both your suggestions.
Has this feature been implemented?
Yes, see https://youtrack.jetbrains.com/issue/WEB-18307#comment=27-2028970