Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables and new lines do not work with new version #136

Open
sveltosss opened this issue Oct 19, 2020 · 10 comments
Open

Variables and new lines do not work with new version #136

sveltosss opened this issue Oct 19, 2020 · 10 comments

Comments

@sveltosss
Copy link

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.

@sergeche
Copy link
Member

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

@sveltosss
Copy link
Author

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.

@sergeche
Copy link
Member

You can user variables like $class

@sveltosss
Copy link
Author

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

@sergeche
Copy link
Member

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 {...}

@sveltosss
Copy link
Author

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.

@sergeche
Copy link
Member

Can you show me you full Emmet config with snippets?

@sveltosss
Copy link
Author

sveltosss commented Oct 19, 2020

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.

@sergeche
Copy link
Member

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

@sveltosss
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants