Skip to content

Instantly share code, notes, and snippets.

@dustypomerleau
Created May 26, 2020 02:32
Show Gist options
  • Save dustypomerleau/4593e0da17fc65b73ed9ae4bdd81c299 to your computer and use it in GitHub Desktop.
Save dustypomerleau/4593e0da17fc65b73ed9ae4bdd81c299 to your computer and use it in GitHub Desktop.
Library/Application\ Support/Code/User/snippets/global.code-snippets
{
"lv_module": {
"scope": "elixir, html-eex",
"prefix": "lv",
"body": [
"defmodule ${1}Web.${2}Live do",
" use ${1}Web, :live_view",
"end"
],
"description": "LiveView module"
},
"lv_mount": {
"scope": "elixir, html-eex",
"prefix": "mount",
"body": [
"def mount(_params, _session, socket) do",
" socket = assign(socket, ${1:key}: ${2:value})",
" {:ok, socket}",
"end"
],
"description": "LiveView mount function"
},
"lv_rend": {
"scope": "elixir, html-eex",
"prefix": "rend",
"body": [
"def render(assigns) do",
" ~L\"\"\"",
" ${0}",
" \"\"\"",
"end"
],
"description": "LiveView render function"
},
"lv_handle_event": {
"scope": "elixir, html-eex",
"prefix": "he",
"body": [
"def handle_event(${1:event}, _, socket) do",
" socket = assign(socket, ${2:key}: ${3:value})",
" {:noreply, socket}",
"end"
],
"description": "LiveView handle_event function"
},
"lv_handle_info": {
"scope": "elixir, html-eex",
"prefix": "hi",
"body": [
"def handle_info(${1:message}, socket) do",
" socket = assign(socket, ${2:key}: ${3:value})",
" {:noreply, socket}",
"end"
],
"description": "LiveView handle_info function"
},
"lv_template": {
"scope": "elixir, html-eex",
"prefix": "lt",
"body": [
"~L\"\"\"",
"${0}",
"\"\"\""
],
"description": "LiveView inline template"
},
"eex_h1": {
"scope": "elixir, html-eex",
"prefix": "h1",
"body": [
"<h1>${0}</h1>"
],
"description": "EEx h1"
},
"eex_div_class": {
"scope": "elixir, html-eex",
"prefix": "div",
"body": [
"<div class=\"${1}\">",
" ${0}",
"</div>",
""
],
"description": "EEx div with class"
},
"eex_div_id": {
"scope": "elixir, html-eex",
"prefix": "divi",
"body": [
"<div id=\"${1}\">",
" ${0}",
"</div>",
""
],
"description": "EEx div with id"
},
"eex_span_class": {
"scope": "elixir, html-eex",
"prefix": "span",
"body": [
"<span class=\"${1}\">",
" ${0}",
"</span>",
""
],
"description": "EEx span with class"
},
"eex_span_style": {
"scope": "elixir, html-eex",
"prefix": "spans",
"body": [
"<span style=\"${1}\">",
" ${0}",
"</span>",
""
],
"description": "EEx span with width"
},
"eex_form": {
"scope": "elixir, html-eex",
"prefix": "form",
"body": [
"<form>",
" ${0}",
"</form>",
""
],
"description": "EEx form"
},
"eex_button": {
"scope": "elixir, html-eex",
"prefix": "button",
"body": [
"<button>",
" ${0}",
"</button>"
],
"description": "EEx button"
},
"eex_img": {
"scope": "elixir, html-eex",
"prefix": "img",
"body": [
"<img src=\"${1}\">"
],
"description": "EEx img"
},
"eex_datalist": {
"scope": "elixir, html-eex",
"prefix": "data",
"body": [
"<datalist id=\"${1}\">",
" ${0}",
"</datalist>",
""
],
"description": "EEx datalist"
},
"eex_input": {
"scope": "elixir, html-eex",
"prefix": "input",
"body": [
"<input type=\"text\" name=\"${1}\" value=\"${2}\"",
" placeholder=\"${3}\" />"
],
"description": "EEx text input"
},
"eex_hidden_input": {
"scope": "elixir, html-eex",
"prefix": "hidden",
"body": [
"<input type=\"hidden\" name=\"${1}\" value=\"${2}\" />"
],
"description": "EEx hidden input"
},
"eex_checkbox_input": {
"scope": "elixir, html-eex",
"prefix": "checkbox",
"body": [
"<input type=\"checkbox\" id=\"${1}\" name=\"${2}\" value=\"${3}\"/>"
],
"description": "EEx checkbox input"
},
"eex_select": {
"scope": "elixir, html-eex",
"prefix": "select",
"body": [
"<select name=\"${1}\">",
"</select>"
],
"description": "EEx select input"
},
"eex_option": {
"scope": "elixir, html-eex",
"prefix": "option",
"body": [
"<option value=\"${1}\">${0}</option>"
],
"description": "EEx option"
},
"eex_label": {
"scope": "elixir, html-eex",
"prefix": "label",
"body": [
"<label for=\"${1}\">${2}</label>"
],
"description": "EEx label"
},
"eex_href": {
"scope": "elixir, html-eex",
"prefix": "a",
"body": [
"<a href=\"#\">${1}</a>"
],
"description": "EEx anchor tag"
},
"eex_render_block": {
"scope": "elixir, html-eex",
"prefix": "et",
"body": [
"<%= $1 %>"
],
"description": "<%= %> render block"
},
"eex_end_tag": {
"scope": "elixir, html-eex",
"prefix": "eend",
"body": [
"<% end %>$1"
],
"description": "<% end %> end tag"
},
"for": {
"scope": "elixir, html-eex",
"prefix": "efor",
"body": [
"<%= for ${1:item} <- @$1s do %>",
" $2",
"<% end %>"
],
"description": "EEx for"
},
"fori": {
"scope": "elixir, html-eex",
"prefix": "efori",
"body": [
"<%= for ${1:item} <- @$1s do %>",
" $2",
"<% end %>"
],
"description": "EEx for comprehension with items"
},
"eex_ifa": {
"scope": "elixir, html-eex",
"prefix": "eifa",
"body": [
"<%= if $1, do: \"{$1}\" %>"
],
"description": "EEx if for attribute"
},
"eex_if": {
"scope": "elixir, html-eex",
"prefix": "eif",
"body": [
"<%= if $1 do %>",
" $2",
"<% end %>"
],
"description": "EEx if"
},
"eex_if_else": {
"scope": "elixir, html-eex",
"prefix": "eife",
"body": [
"<%= if $1 do %>",
" $2",
"<% else %>",
" $3",
"<% end %>"
],
"description": "EEx if else"
},
"eex_else": {
"scope": "elixir, html-eex",
"prefix": "eelse",
"body": [
"<% else %>"
],
"description": "EEx else"
},
"eex_cond": {
"scope": "elixir, html-eex",
"prefix": "econd",
"body": [
"<%= cond do %>",
" <% $1 -> %>",
" $2",
" <% true -> %>",
" $3",
"<% end %>"
],
"description": "EEx cond"
},
"eex_unless": {
"scope": "elixir, html-eex",
"prefix": "eunless",
"body": [
"<%= unless $1 do %>",
" $2",
"<% end %>"
],
"description": "EEx unless"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment