Skip to content

Latest commit

 

History

History
617 lines (575 loc) · 10.4 KB

README.md

File metadata and controls

617 lines (575 loc) · 10.4 KB

Edge templates extension for VSCode




This is the official extension for VSCode created by the creators of Edge.js. The extension adds support for the following features.

Important

This extension does not perform code formatting.

Code formatting with template engine syntax embedded inside HTML is tricky and needs dedicated resources to fight edge cases. We do not have the bandwidth to work on the same right now.

Configuration

Following is the list of available configuration options :

edge.disks

In order to benefit from autocompletion and Go-To links, the extension needs to know the directories hosting your Edge templates.

That's what this option is for : it's an object whose keys are the disk names and values the paths to the template directories, relative to the root of your project.

By default, edge.disk has this value:

{
  "edge.disks": {
    "default": "resources/views"
  }
}

This is perfectly suited to AdonisJS projects by default.

If you set up a secondary disk with Edge, like this

const BASE_URL = new URL('./', import.meta.url)
edge.mount('mydisk', new URL('my/sub/directory', BASE_URL))

You can configure the extension as follows:

{
  "edge.disks": {
    "default": "resources/views",
    "mydisk": "my/sub/directory"
  }
}

If you are using packages such as edge-uikit or @dimer/docs-theme which add extra templates, you can configure new disks like this:

{
  "edge.disks": {
    "default": "resources/views",
    "docs": "node_modules/dimerapp/docs-theme/build/templates",
    "ui": "node_modules/edge-uikit/build/views"
  }
}

Emmet support

If you want to use Emmet in your Edge templates, you can add the following configuration:

{
  "emmet.includeLanguages": {
    "edge": "html"
  }
}

Tags snippets

Following is the list of available snippets

Triggers Output
if
@if(TAB_STOP_1)
  TAB_STOP_2
@end
elseif
@elseif(TAB_STOP_1)
  TAB_STOP_2
else
@else
  TAB_STOP_1
if-else
@if(TAB_STOP_1)
  TAB_STOP_2
@else
  TAB_STOP_3
@end
unless
@unless(TAB_STOP_1)
  TAB_STOP_2
@end
each
@each(TAB_STOP_1 in TAB_STOP_2)
  TAB_STOP_3
@end
each-index
@each((TAB_STOP_1, TAB_STOP_2) in TAB_STOP_3)
  TAB_STOP_4
@end
component
@component('components/')
  TAB_STOP
@end
component-inline
@!component('components/')
slot
@slot('TAB_STOP_1')
  TAB_STOP_2
@end
inject
@inject(TAB_STOP_1)
eval
@eval(TAB_STOP_1)
newError
@newError(
  'TAB_STOP_1',
  $caller.filename,
  $caller.line,
  $caller.col
)
include
@include('partials/')
include-if
@includeIf(TAB_STOP_1, 'partials/')
svg
@svg('TAB_STOP_1')
debugger
@debugger
let
@let(TAB_STOP_1 = 'TAB_STOP_2')
assign
@assign(TAB_STOP_1 = 'TAB_STOP_2')
vite
@vite('TAB_STOP_1')

Inbuilt helpers snippets

Triggers Output
props.toAttrs
$props.toAttrs()
props.merge
$props
  .merge({ TAB_STOP_1 })
  .toAttrs()
props.only
$props
  .only(['TAB_STOP_1'])
  .toAttrs()
props.except
$props
  .except(['TAB_STOP_1'])
  .toAttrs()
slots
await $slots.TAB_STOP_1
filename
$filename
caller
$caller.filename
$caller.line
$caller.col
nl2br
nl2br(html.escape(TAB_STOP))
inspect
inspect(TAB_STOP_1)
truncate
truncate(TAB_STOP_1, TAB_STOP_2)
excerpt
excerpt(TAB_STOP_1, TAB_STOP_2)
html
html.escape(TAB_STOP)
html.safe(TAB_STOP)
html.classNames(TAB_STOP)
html.attrs(TAB_STOP)
stringify
js.stringify(TAB_STOP_1)
camelCase
camelCase(TAB_STOP_1)
snakeCase
snakeCase(TAB_STOP_1)
dashCase
dashCase(TAB_STOP_1)
pascalCase
pascalCase(TAB_STOP_1)
capitalCase
capitalCase(TAB_STOP_1)
capitalCase
capitalCase(TAB_STOP_1)
sentenceCase
sentenceCase(TAB_STOP_1)
dotCase
dotCase(TAB_STOP_1)
noCase
noCase(TAB_STOP_1)
titleCase
titleCase(TAB_STOP_1)
pluralize
pluralize(TAB_STOP_1)
sentence
sentence(TAB_STOP_1)
prettyMs
prettyMs(TAB_STOP_1)
toMs
toMs(TAB_STOP_1)
prettyBytes
prettyBytes(TAB_STOP_1)
toBytes
toBytes(TAB_STOP_1)
ordinal
ordinal(TAB_STOP_1)

AdonisJS-specific snippets

Triggers Output
route
route('TAB_STOP_1', [TAB_STOP_2])
signedRoute
signedRoute('TAB_STOP_1', [TAB_STOP_2])
flashMessages
flashMessages.has(TAB_STOP)
flashMessages.get(TAB_STOP)
asset
asset('TAB_STOP_1')
csrfField
csrfField()
cspNonce
cspNonce()
auth
auth.user
auth.isAuthenticated
config
config('TAB_STOP_1')
t
t('TAB_STOP_1', { TAB_STOP_2 })