vim - Generate random id in neosnippet html snippets -


I am using neosnippet addon for auto-completion of code templates, and I have a cutom snippet that looks like this From ( Html.snip ):

  snippet amyhyide & lt; P & gt; Input type = "button" onclick = "return toggle ('$ {1: hideID}')" value = "toggle show / hide" & gt; & Lt; / P & gt; & Lt; Div id = "$ 1" & gt; & Lt; / Div & gt;  

Since it can be used multiple times in an HTML file, I have to ensure that each hideID is unique, so I am wondering if my It is possible for VIM to work, generate a random letter-numeric ID of just 12 and keep it there.

Neosnipate documents:

  Vim has an inbuilt expression evaluation You can also use this feature inside the snippets if you use the back type as the examples given below, "%: t" extends over the name of the current active file and the current time is the output of the streamtime command Being inserted by the extension of Is there. Snippet header file: $ {1: `expand ('%: T')`} $ {2: Created on: `Strawberry ("% B% d,% Y ")}}   

API does not come in an inherent way to generate random stuff, but, in the spirit of real unix, we can work.

You should do this snippet:

  Snippet Amahid & lt; P & gt; & Lt; Input onclick = "return toggle ('$ {1:` system ("date +% s | shasum | base64 | head -c 10; echo") `}')" & gt; & Lt; / P & gt; & Lt; Div id = "$ 1" & gt; & Lt; / Div & gt;  

I do not have Neopipat but this feature is also in the original snippet. This snippet:

  Snippet AmiHide & lt; P & gt; & Lt; Input onclick = "toggle back Mai ('$ {1:` system ("date +% s | shasum | base64 | head -c 10; echo") `}'); & gt; & Lt; / P & gt; & Lt; Div id = "$ 1" & gt; & Lt; / Div & gt;  

Gives me this block of HTML:

  & lt; P & gt; & Lt; Input onclick = "return toggle ('ZjE5MjJkNT')" & gt; & Lt; / P & gt; & Lt; Div id = "ZjE5MjJkNT" & gt; & Lt; / Div & gt;  

YMMV


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -