From 98393298372d6a3c34e503da58f495cfba715098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Dierick?= Date: Wed, 1 Jun 2022 17:48:27 +0200 Subject: [PATCH 1/3] fix bug where toggling between route and controller appends hbs vs js --- lib/ember-cli-helper-view.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ember-cli-helper-view.coffee b/lib/ember-cli-helper-view.coffee index c48fe4f..58efb26 100644 --- a/lib/ember-cli-helper-view.coffee +++ b/lib/ember-cli-helper-view.coffee @@ -184,13 +184,13 @@ class EmberCliHelperView extends View if paths[0] == 'routes' paths.shift() basePaths = ["controllers"].concat(paths) - possiblePaths = @generatePossiblePaths(basePaths, fileName, TEMPLATE_EXTENSIONS) + possiblePaths = @generatePossiblePaths(basePaths, fileName, SCRIPT_EXTENSIONS) # controllers/*.js -> routes/*.js else if paths[0] == 'controllers' paths.shift() basePaths = ["routes"].concat(paths) - possiblePaths = @generatePossiblePaths(basePaths, fileName, TEMPLATE_EXTENSIONS) + possiblePaths = @generatePossiblePaths(basePaths, fileName, SCRIPT_EXTENSIONS) # template to script else if extension in TEMPLATE_EXTENSIONS From 6062c1902d7d3dc405d6c76c336a82486714e183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Dierick?= Date: Wed, 1 Jun 2022 17:50:55 +0200 Subject: [PATCH 2/3] add support for angle-bracket component invocation --- lib/ember-cli-helper-view.coffee | 19 ++++++++++++------- package.json | 3 ++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/ember-cli-helper-view.coffee b/lib/ember-cli-helper-view.coffee index 58efb26..a15da1a 100644 --- a/lib/ember-cli-helper-view.coffee +++ b/lib/ember-cli-helper-view.coffee @@ -1,5 +1,6 @@ {Task, BufferedProcess} = require 'atom' {$, View} = require 'atom-space-pen-views' +{dasherize} = require 'ember-cli-string-utils' GeneratorListView = require './generator-list-view' {TEMPLATE_EXTENSIONS, SCRIPT_EXTENSIONS, STYLE_EXTENSIONS} = require './constants' path = require 'path' @@ -279,13 +280,17 @@ class EmberCliHelperView extends View cursor = editor.getCursorBufferPosition() line = editor.buffer.lineForRow(cursor.row) - startColumn = line.substring(0, cursor.column).lastIndexOf('{{') - return if startColumn == -1 - - line = line.substring(startColumn + 2) - line = line.substring(1) if line.indexOf('#') == 0 - - componentName = line.split(/[^A-Za-z0-9\/\-_]/)[0] + abStartColumn = line.substring(0, cursor.column).lastIndexOf('<') + mStartColumn = line.substring(0, cursor.column).lastIndexOf('{{') + if abStartColumn >= 0 # Angle brackets invocation + abComponentName = line.match(/(?<=)[A-Z][A-Za-z:]*/)[0] + componentName = abComponentName.split('::').map(dasherize).join('/') + else if mStartColumn >= 0 # Mustache invocation + line = line.substring(startColumn + 2) + line = line.substring(1) if line.indexOf('#') == 0 + componentName = line.split(/[^A-Za-z0-9\/\-_]/)[0] + else + return if componentName && componentName.indexOf('-') > 0 basePaths = ["templates", "components"] diff --git a/package.json b/package.json index 92493a6..57114ef 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "atom": ">=0.174.0 <2.0.0" }, "dependencies": { - "atom-space-pen-views": "^2.0.4" + "atom-space-pen-views": "^2.0.4", + "ember-cli-string-utils": "^1.1.0" } } From df385ade9c1e60da4c0b1190647e5b41007e1e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Dierick?= Date: Wed, 1 Jun 2022 17:51:16 +0200 Subject: [PATCH 3/3] switch to octane component layout --- lib/ember-cli-helper-view.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/ember-cli-helper-view.coffee b/lib/ember-cli-helper-view.coffee index a15da1a..a2063df 100644 --- a/lib/ember-cli-helper-view.coffee +++ b/lib/ember-cli-helper-view.coffee @@ -140,7 +140,8 @@ class EmberCliHelperView extends View if extension in SCRIPT_EXTENSIONS # components/*.js -> templates/components/*.hbs if paths[0] == 'components' - basePaths = ["templates"].concat(paths) + # basePaths = ["templates"].concat(paths) # pre-octane + basePaths = paths # octane possiblePaths = @generatePossiblePaths(basePaths, fileName, TEMPLATE_EXTENSIONS) # controllers/*.js -> templates/*.hbs @@ -153,8 +154,9 @@ class EmberCliHelperView extends View # template to script else if extension in TEMPLATE_EXTENSIONS # templates/components/*.hbs -> components/*.js - if paths[0] == 'templates' && paths[1] == 'components' - paths.shift() + # if paths[0] == 'templates' && paths[1] == 'components' # pre-octane + if paths[0] == 'components' # octane + # paths.shift() # pre-octane possiblePaths = @generatePossiblePaths(paths, fileName, SCRIPT_EXTENSIONS) # templates/xyz/*.hbz -> controllers/ @@ -292,8 +294,9 @@ class EmberCliHelperView extends View else return - if componentName && componentName.indexOf('-') > 0 - basePaths = ["templates", "components"] + if componentName + # basePaths = ["templates", "components"] # pre-octane + basePaths = ["components"] # octane fileNameParts = componentName.split("/") fileName = fileNameParts.pop() basePaths = basePaths.concat(fileNameParts)