Phoenix View Extension

By Pikender Sharma April 25, 2016

The post belongs to NectarCommerce and Extension Framework Awareness Series

  1. NectarCommerce Vision
  2. Extension Framework Game Plan
  3. Introduction to Metaprogramming
  4. Ecto Model Schema Extension
  5. Ecto Model Support Functions Extension
  6. Phoenix Router Extension
  7. Phoenix View Extension
  8. Running Multiple Elixir Apps Together
  9. Extension Approach Explained
  10. Learning from failures: First Experiment at NectarCommerce Extension Approach
  11. Developing NectarCommerce Extensions
  12. Building an exrm release including NectarCommerce

What will be NectarCommerce

Off-the-shelf Opensource E-commerce application for building an online store.

Provides an Extension Framework to support features not included in core as extensions.

Strives for unobtrusive parallel development of NectarCommerce and Extensions

NectarCommerce is committed to providing a ready-to-use e-commerce solution but the definition of 100% is different under different business domains. It aims to solve common use-cases as part of the project and relying on extension framework to tap the rest.

Phoenix View Extension


We want to allow Extensions to provide alternate view for an existing view in Nectar or provide an alternate template path for all views without changing the Nectar Views.


Note: Please refer Introduction to Metaprogramming for more information on Metaprogramming in Elixir

Alternate View Templates Path than Default for all templates override

To fully understand the changes below, please refer Phoenix View Implementation

As per the reference above, we simply defined a function which adds the ability to check custom path for templates and if not found will fallback to default view paths 🙂

Only Few Template Overrides than all

Note: This section would be very similar to Ecto Model Support Functions Extension, so only complete code-snippets are shown and not incremental walkthrough

Check the library code, service code and consumer code as used with Nectar Wallet Extension

Library Code

Service Code

Consumer Code

Partial Override from Extension

Our aim with these posts is to start a dialog with the Elixir community on validity and technical soundness of our approach. We would really appreciate your feedback and reviews, and any ideas/suggestions/pull requests for improvements to our current implementation or entirely different and better way to do things to achieve the goals we have set out for NectarCommerce.

Enjoy the Elixir potion !!

Share this:

Leave a comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center