@herb-tools/formatter 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -243,7 +243,7 @@ class Token {
243
243
  }
244
244
 
245
245
  // NOTE: This file is generated by the templates/template.rb script and should not
246
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.3/templates/javascript/packages/core/src/errors.ts.erb
246
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/errors.ts.erb
247
247
  class HerbError {
248
248
  type;
249
249
  message;
@@ -773,7 +773,7 @@ function convertToUTF8(string) {
773
773
  }
774
774
 
775
775
  // NOTE: This file is generated by the templates/template.rb script and should not
776
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.3/templates/javascript/packages/core/src/nodes.ts.erb
776
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/nodes.ts.erb
777
777
  class Node {
778
778
  type;
779
779
  location;
@@ -3007,7 +3007,7 @@ class ParseResult extends Result {
3007
3007
  }
3008
3008
 
3009
3009
  // NOTE: This file is generated by the templates/template.rb script and should not
3010
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.3/templates/javascript/packages/core/src/node-type-guards.ts.erb
3010
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/node-type-guards.ts.erb
3011
3011
  /**
3012
3012
  * Type guard functions for AST nodes.
3013
3013
  * These functions provide type checking by combining both instanceof
@@ -3504,7 +3504,7 @@ function getNodesAfterPosition(nodes, position, inclusive = true) {
3504
3504
  }
3505
3505
 
3506
3506
  // NOTE: This file is generated by the templates/template.rb script and should not
3507
- // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.3/templates/javascript/packages/core/src/visitor.ts.erb
3507
+ // be modified manually. See /Users/marcoroth/Development/herb-release-0.8.4/templates/javascript/packages/core/src/visitor.ts.erb
3508
3508
  class Visitor {
3509
3509
  visit(node) {
3510
3510
  if (!node)
@@ -4987,13 +4987,30 @@ class FormatPrinter extends Printer {
4987
4987
  * Render multiline attributes for a tag
4988
4988
  */
4989
4989
  renderMultilineAttributes(tagName, allChildren = [], isSelfClosing = false) {
4990
- this.pushWithIndent(`<${tagName}`);
4990
+ const herbDisableComments = allChildren.filter(child => isNode(child, ERBContentNode) && isHerbDisableComment(child));
4991
+ let openingLine = `<${tagName}`;
4992
+ if (herbDisableComments.length > 0) {
4993
+ const commentLines = this.capture(() => {
4994
+ herbDisableComments.forEach(comment => {
4995
+ const wasInlineMode = this.inlineMode;
4996
+ this.inlineMode = true;
4997
+ this.lines.push(" ");
4998
+ this.visit(comment);
4999
+ this.inlineMode = wasInlineMode;
5000
+ });
5001
+ });
5002
+ openingLine += commentLines.join("");
5003
+ }
5004
+ this.pushWithIndent(openingLine);
4991
5005
  this.withIndent(() => {
4992
5006
  allChildren.forEach(child => {
4993
5007
  if (isNode(child, HTMLAttributeNode)) {
4994
5008
  this.pushWithIndent(this.renderAttribute(child));
4995
5009
  }
4996
5010
  else if (!isNode(child, WhitespaceNode)) {
5011
+ if (isNode(child, ERBContentNode) && isHerbDisableComment(child)) {
5012
+ return;
5013
+ }
4997
5014
  this.visit(child);
4998
5015
  }
4999
5016
  });