diff options
author | Sam Seay <sam@manuka.co> | 2016-09-01 09:43:23 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-01 09:43:23 +1200 |
commit | 3b5120b087182cb96a1a2082a5fb149276e45304 (patch) | |
tree | 53f44594fbac8a78ddf7d1fec99779ba310f4e00 /lib/recaptcha/template.ex | |
parent | 7ff101f0fa5aaf52df07d37584472521c4b3cc55 (diff) | |
download | recaptcha-3b5120b087182cb96a1a2082a5fb149276e45304.tar.gz recaptcha-3b5120b087182cb96a1a2082a5fb149276e45304.tar.xz |
Feature/v2 rewrite (#7)
Rewrite of the API.
* Change the copyright holder since its a rewrite.
* Bump dependencies to their latest versions.
* Revision of the README to document the new API
* Break config up into keyword list (no longer a map)
* A rewrite of the recaptcha verify API and move of templating into Recaptcha.Template
* Add tests and credo for code style
* Remove exception raising method calls (`HTTPoison.post!` and `Poison.decode!`)
* Change Elixir version to 1.2 for `with` support.
Diffstat (limited to 'lib/recaptcha/template.ex')
-rw-r--r-- | lib/recaptcha/template.ex | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/recaptcha/template.ex b/lib/recaptcha/template.ex new file mode 100644 index 0000000..d644266 --- /dev/null +++ b/lib/recaptcha/template.ex @@ -0,0 +1,25 @@ +defmodule Recaptcha.Template do + @moduledoc """ + Responsible for rendering boilerplate recaptcha HTML code, supports noscript fallback. + + Currently the [explicit render](https://developers.google.com/recaptcha/docs/display#explicit_render) functionality + is not supported. + + In future this module may be separated out into a Phoenix specific library. + """ + require Elixir.EEx + + EEx.function_from_file :defp, :render_template, "lib/template.html.eex", [:assigns] + + @public_key Application.get_env(:recaptcha, :public_key) + + @doc """ + Returns a string with reCAPTCHA code + + To convert the string to html code, use Phoenix.HTML.Raw/1 method + """ + def display(options \\ []) do + public_key = options[:public_key] || @public_key + render_template(public_key: public_key, options: options) + end +end |