Skip to content

Intial support for vsCodeTagSnippets#589

Merged
phalaphone merged 4 commits into
masterfrom
vscodeTagSnippets
Feb 26, 2021
Merged

Intial support for vsCodeTagSnippets#589
phalaphone merged 4 commits into
masterfrom
vscodeTagSnippets

Conversation

@phalaphone

@phalaphone phalaphone commented Jan 25, 2021

Copy link
Copy Markdown
Contributor

Added new method to produce a string of tag snippets formatted for use in the hubspot vscode plugin.

Updated
(1/29) Output:

{% import ${1:path} ${2:import_name} %}

{% elif ${1:condition} %}

{% autoescape %}
{% endautoescape %}

{% from ${1:path} ${2:macro_name} %}

{% macro ${1:macro_name} ${2:argument_names} %}
{% endmacro %}

{% raw %}
{% endraw %}

{% else %}

{% if ${1:condition} %}
{% endif %}

{% print ${1:expr} %}

{% do %}

{% cycle ${1:string_to_print} %}

{% unless ${1:expr} %}
{% endunless %}

{% include ${1:path} %}

{% ifchanged %}
{% endifchanged %}

{% set ${1:var} = ${2:expr} %}

{% block ${1:block_name} %}
{% endblock %}

{% call %}
{% endcall %}

{% extends ${1:path} %}

{% for ${1:items_to_iterate} %}
{% endfor %}

@phalaphone phalaphone requested a review from mattcoley January 25, 2021 22:08

@mattcoley mattcoley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒 Looks like if/elif are missing the jinjavaparam in the doc, can you add it here?

@mattcoley

Copy link
Copy Markdown
Collaborator

I think set tag is a bit custom here since I think you want {% set ${1:var} = ${2:expr} %}. Maybe it is worth adding a new annotation to specify an override for this custom behavior on the few tags that we need to adjust the snippet?

@phalaphone

Copy link
Copy Markdown
Contributor Author

I updated the output in at the top of the page. I did notice for a lot of them (i.e. if, else, macro, etc.) We have no jinjava annotation for body, would it be worthwhile to add that so we can represent where code would go in an if statement for example?

@anthmatic

anthmatic commented Feb 3, 2021

Copy link
Copy Markdown
Contributor

we can represent where code would go

@phalaphone do you mean something like this?

{% if ${1:condition} %}
  $0
{% endif %}

If so, I think that would be helpful. Each ${} tag is a tabbable placeholder in VSCode and $0, $1, etc... are tab stops

import com.hubspot.jinjava.doc.annotations.JinjavaMetaValue;
import com.hubspot.jinjava.doc.annotations.JinjavaParam;
import com.hubspot.jinjava.doc.annotations.JinjavaSnippet;
import com.hubspot.jinjava.doc.annotations.JinjavaVSCodeSnippet;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this should be VSCode specific. This syntax is technically borrowed from Textmate and other editors use a similar format so I think this could be used across other editors pretty easily

@phalaphone

Copy link
Copy Markdown
Contributor Author

@mattcoley @anthmatic

Here is the current list:

{% import ${1:path} ${2:import_name} %}

{% elif ${1:condition} %}
${2:Code}

{% autoescape %}
{% endautoescape %}

{% from ${1:path} ${2:macro_name} %}

{% macro ${1:macro_name} ${2:argument_names} %}
${3:Code}
{% endmacro %}

{% raw %}
{% endraw %}

{% else %}
${1:Code}

{% if ${1:condition} %}
${2:Code}
{% endif %}

{% print ${1:expr} %}

{% do %}

{% cycle ${1:string_to_print} %}

{% unless ${1:expr} %}
${2:Code}
{% endunless %}

{% include ${1:path} %}

{% ifchanged %}
${1:Code}
{% endifchanged %}

{% set ${1:var} = ${2:expr} %}

{% block ${1:block_name} %}
{% endblock %}

{% call %}
{% endcall %}

{% extends ${1:path} %}

{% for ${1:items_to_iterate} %}
${2:Code}
{% endfor %}

Any changes before we get this out as a starting point?

@anthmatic

Copy link
Copy Markdown
Contributor

Thanks @phalaphone! I made some changes to some snippets below:

{% import '${1:path}' ${2: as ${3:import_name}} %}

{% elif ${1:condition} %}
$0

{% autoescape %}
{% endautoescape %}

{% from '${1:path}' import ${2:macro_name} %}

{% macro ${1:macro_name}(${2:argument_names}) %}
$0
{% endmacro %}**

{% raw %}
{% endraw %}

{% else %}
$0

{% if ${1:condition} %}
$0
{% endif %}

{% print ${1:expr} %}

{% do ${1:expr} %}

{% cycle ${1:string_to_print} %}

{% unless ${1:expr} %}
$0
{% endunless %}

{% include '${1:path}' %}

{% ifchanged %}
$0
{% endifchanged %}

{% set ${1:var} = ${2:expr} %}

{% block ${1:block_name} %}
$0
{% endblock {$1} %}

{% call ${1:macro_name}(${2:argument_names}) %}
$0
{% endcall %}

{% extends '${1:path}' %}

{% for ${1:items} in ${2:list} %}
{{ ${1} }}$0
{% endfor %}```

The most notable change is that the code placeholder should just be `$0`, but there are a bunch of small changes to most of these. Let me know if you have any questions about any changes.

@phalaphone phalaphone merged commit f5fa978 into master Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants