{"id":32167427,"url":"https://github.com/nmbrone/gonex","last_synced_at":"2026-05-14T20:02:12.127Z","repository":{"id":62429857,"uuid":"222694542","full_name":"nmbrone/gonex","owner":"nmbrone","description":"Get your Phoenix variables in your Javascript","archived":false,"fork":false,"pushed_at":"2019-12-18T10:16:44.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-20T04:11:53.960Z","etag":null,"topics":["convenient","elixir","helpers-library","javascript","phoenix","phoenix-controller","phoenix-elixir"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nmbrone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-19T12:46:56.000Z","updated_at":"2019-12-18T10:16:46.000Z","dependencies_parsed_at":"2022-11-01T20:06:34.166Z","dependency_job_id":null,"html_url":"https://github.com/nmbrone/gonex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nmbrone/gonex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmbrone%2Fgonex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmbrone%2Fgonex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmbrone%2Fgonex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmbrone%2Fgonex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nmbrone","download_url":"https://codeload.github.com/nmbrone/gonex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmbrone%2Fgonex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33041204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convenient","elixir","helpers-library","javascript","phoenix","phoenix-controller","phoenix-elixir"],"created_at":"2025-10-21T15:29:21.962Z","updated_at":"2026-05-14T20:02:12.122Z","avatar_url":"https://github.com/nmbrone.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gonex - get your Phoenix variables in your Javascript\n\n[![Actions Status](https://github.com/nmbrone/gonex/workflows/build/badge.svg?branch=master)](https://github.com/nmbrone/gonex/actions)\n[![Hex version badge](https://img.shields.io/hexpm/v/gonex.svg)](https://hex.pm/packages/gonex)\n\nGonex is a super simple implementation of [gon](https://github.com/gazay/gon) but for [Phoenix](https://www.phoenixframework.org/) \nprojects and it's a convenient way to send some data from your controller to your JavaScript.\n\n## Installation\n\nThe package can be installed by adding `gonex` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:gonex, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\nFirst in your layout view:\n\n```elixir\ndefmodule MyAppWeb.LayoutView do\n  use MyAppWeb, :view\n  \n  # Import Gonex view helpers\n  import Gonex.View\n  \n  def render(\"app.html\", assigns) do\n    ~E\"\"\"\n    \u003c!-- ... --\u003e\n    \u003c%= render_gon(assigns.conn, \"myAppGon\") %\u003e\n    \u003c!-- ... --\u003e\n    \"\"\"\n  end\nend\n```\n\nThen in your controller:\n\n```elixir\ndefmodule MyAppWeb.PageController do\n  use MyAppWeb, :controller\n  \n  # Import Gonex controller helpers.\n  # Alternatively you can import this in your MyAppWeb :controller definition \n  # and make Gonex available within all of your controllers\n  import Gonex.Controller\n  \n  def index(conn, _params) do\n    conn\n    |\u003e put_gon(greeting: \"Hello, World!\") # put something useful here\n    |\u003e render(\"index.html\")\n  end\nend\n```\n\nFinally in you JavaScript:\n\n```javascript\nalert(window.myAppGon.greeting); // \"Hello, World!\"\n```\n\nSometimes you will need to have a basic (or initial) set of variables across all of your views. \nThis can be easily achieved with the custom plug:\n\n```elixir\ndefmodule MyAppWeb.PutGonPlug do\n  def init(opts), do: opts\n  \n  def call(conn, _opts) do\n    Gonex.Controller.put_gon(conn, %{\n      env: Application.get_env(:my_app, :env),\n      locale: Gettext.get_locale(MyAppWeb.Gettext)\n    })\n  end\nend\n```\n\nThen in your router:\n\n```elixir\ndefmodule MyAppWeb.Router do\n  use MyAppWeb, :router\n\n  pipeline :browser do\n    # ...\n    plug MyAppWeb.PutGonPlug\n    # ...\n  end\nend\n```\n\n## Documentation\n\nThe docs can be found at [https://hexdocs.pm/gonex](https://hexdocs.pm/gonex).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmbrone%2Fgonex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmbrone%2Fgonex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmbrone%2Fgonex/lists"}