Comments (3)
@Renjaminino thanks for the reply. @sighmon here's some extra info.
Again not the most avid Rails/ruby dev so take this with a pinch of salt, but I don't see this belonging the controller responsability.
What i meant with custom-components
are actually extensions of the mjml
markup language, which is already possible with the js/node library. ( I've referenced the links the issue description how you can create those).
So let's picture this:
- Mjml components are written in javascript, as the mjml itself.
- I have custom component, named
<mj-island>
, this has an associated .js file that lives inmy-mjml-components/mj-island.js
. (most real scenario will be innode_modules
but let's keep with this for example purposes) - I should be able to register this component in the
mjml
instance (or bin) (like you can when usingregisterComponent()
with the direct mjml javascript library) - After that this should just workβ’
<mjml> <mj-body> <mj-island /> </mj-body> </mjml>
A yet untested assumption on how to make it work
There might be an mjml-core
configuration option that can help us here: packages
. The current documentation barely mentions its existence and usage, but this particular piece of documentation on community components) references it
// .mjmlconfig
{
packages: [
"path/to/my-mjml-components/mj-insland.js"
]
}
So apparently we can pass a custom config file .mjmlconfig
to the cli
, and the packages key allow us to specify an Array
of custom components paths
The option available to the CLI is mjml --config.mjmlConfigPath <path>
The path or directory of the
.mjmlconfig
file (for custom components use)
Assumption
So i assume that maybe it's possible to feed our mjml BIN with custom components, judging by this line of code
Line 38 in c7f5b24
Which could become
# removed the beautify options for brevity, we can merge them with the config file
command = "#{mjml_bin} -r #{in_tmp_file} -o #{out_tmp_file.path} --config.mjmlConfigPath #{configPath}"
#initalizers/mjml.rb
Mjml.setup do |config|
config.configPath = "#{Rails.root}/.mjmlconfig" # or an hash directly?
end
Now, the question for you guys: how delusional am I? π
I'll try to do a couple of tests myself, if I find that i'm crazy i'll come here and say sorry for wasting your time, if not i'll try to make a PR.
Cheers,
R
from mjml-rails.
That's a good point Renato.
I'm curious how that might be done. I know that if you run mjml in isolation, you can still import the content / partials, as long as the versions are the same. In theory you could import a deprecated mjml product into a ruby environment but it might give you compatibility warnings during compilation.
I need to actually try this myself, but once the controller in rails is set to run and compile mjml, you should be able to build a custom component, add any extra settings into your controller, and voila. All rails needs is to register where this formerly isolated component, is residing.
There was a discussion at some point, on building a controller that simply detects all the files within the mjml rails structure and works with them, even if you imported custom components. As long as they paths matched your setup.
Cheers,
R.
from mjml-rails.
@renatodeleao @Renjaminino I've never needed to build my own custom components, so I'm not going to be much help. But look forward to your pull request.
from mjml-rails.
Related Issues (20)
- Update GitHub actions
- [Bug] Does not find MJML executable with npm 9+ (yarn 2+ uses npm discovery) HOT 2
- Slow to render layout, and too much object(memory) Allocations HOT 1
- Prevents booting when `which` is missing HOT 8
- Can i override a layout? HOT 1
- How to custom template path? HOT 1
- Add config option for fonts HOT 1
- Fix test pipeline for Ruby 2.7
- Warning about MJML missing when using MRML HOT 5
- Database template support HOT 1
- image_tag helper in MJML template HOT 2
- MJML not found with NVM setup HOT 3
- Support JSON MJML templates HOT 1
- Support variables as used in Mailjet HOT 6
- Fix tests
- RuboCop? HOT 2
- `Mjml::Parser#render` suppresses errors in case of Tempfile exceptions HOT 2
- Exit code in case of an error when calling the mjml binary HOT 3
- SIGKILL (signal 9) on many concurrent emails HOT 3
- How to use this library to generate a string of raw html? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mjml-rails.