sublime-text-plugin icon indicating copy to clipboard operation
sublime-text-plugin copied to clipboard

Variables and new lines do not work with new version

Open sveltosss opened this issue 5 years ago • 10 comments

Hi.

I'm trying to convert my old snippets to the new format but some basic staff does not work anymore.

I need to access variables and insert new lines like the example shown here with the "for" abbreviation.

https://docs.emmet.io/customization/snippets/

"for": "for (var ${class} = 0; i < ${id}.length; ${class}++) {\n\t|}"

This does not work with emmet.

sveltosss avatar Oct 19 '20 08:10 sveltosss

Since snippets are aliases for Emmet abbreviations, you should wrap it’s contents with {...} to make it a text node with arbitrary contents.

Also note it’s better to add such snippets as native ST snippets, not Emmet

sergeche avatar Oct 19 '20 09:10 sergeche

Thanks.

So there is not an equivalent to old parameter and new line handling ? For example I need to reference class several times in my custom input snippet.

sveltosss avatar Oct 19 '20 09:10 sveltosss

You can user variables like $class

sergeche avatar Oct 19 '20 10:10 sergeche

I tried but it doesn't work.

Here is one of the old snippets I'm trying to make it work.

"in:array": "<input class=\"validate[minCheckbox[1]] checkbox\" type=\"checkbox\" id=\"${id}\" name=\"${class}\\[]\" value=\"1\" \n<?php\nif (\\$${id} === '1') {\n echo ' checked=\"checked\"';\n}\n?>>",

I call it like this: in:array.test1$test2

As you can see I use new lines to format the output as I want.

Is this possible anymore?

Thank you

sveltosss avatar Oct 19 '20 10:10 sveltosss

As I mentioned earlier, snippets are aliases to Emmet abbreviations so you should write snippet value as Emmet abbreviations. For arbitrary text, you should wrap contents with {...}

sergeche avatar Oct 19 '20 12:10 sergeche

Thanks although I don't get what you mean :)

I tried creating my abbreviations from scratch with the new logic but I can't. Older version was much easier to understand and work with. I think there should exist a backwards compatibility or at least a guide how to convert old abbreviations.

Thank you anyway for your time. Appreciate it.

sveltosss avatar Oct 19 '20 12:10 sveltosss

Can you show me you full Emmet config with snippets?

sergeche avatar Oct 19 '20 12:10 sergeche

You mean the old one not working at all?

The new one is almost empty since I'm trying to make at least one of my old abbreviations work like the one I posted above:

in:array": "<input class=\"validate[minCheckbox[1]] checkbox\" type=\"checkbox\" id=\"${id}\" name=\"${class}\\[]\" value=\"1\" \n<?php\nif (\\$${id} === '1') {\n echo ' checked=\"checked\"';\n}\n?>>

This used to work like this if I typed in:array.test$test1

image

I think I need just one to make it work so that I understand how things have changed.

sveltosss avatar Oct 19 '20 12:10 sveltosss

Looks like it it doesn’t work as expected in new Emmet. Will fix it later. For now, you can use native ST snippets instead

sergeche avatar Oct 19 '20 13:10 sergeche

Thank you!

sveltosss avatar Oct 19 '20 13:10 sveltosss