Phoenix View Extension

综合编程 Vinsol

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. Developer Experience and Workflow developing Favorite Product Extension
  11. Developer Experience and Workflow testing Favorite Product Extension

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

Why

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.

How

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

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 !!

稿源:Vinsol (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Phoenix View Extension

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录