Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the location where the new emails get generated. #93

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions spec/tasks/email_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe Gen::Email do
generator = Gen::Email.new
generator.output = IO::Memory.new
generator.print_help_or_call ["PasswordReset"]
generator.output.to_s.should contain("src/emails/password_reset_email.cr")
generator.output.to_s.should contain("src/emails/templates/password_reset_email/html.ecr")

folder = generator.email_template.template_folder
Expand All @@ -21,6 +22,7 @@ describe Gen::Email do
generator = Gen::Email.new
generator.output = IO::Memory.new
generator.print_help_or_call ["WelcomeUserEmail"]
generator.output.to_s.should contain("src/emails/welcome_user_email.cr")
generator.output.to_s.should contain("src/emails/templates/welcome_user_email/html.ecr")

folder = generator.email_template.template_folder
Expand Down
18 changes: 10 additions & 8 deletions src/carbon/tasks/gen/email.cr
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ class Carbon::EmailTemplate

def template_folder
LuckyTemplate.create_folder do |top_dir|
top_dir.add_folder(Path["src/emails/templates"]) do |templates_dir|
templates_dir.add_file("#{@email_filename}_email.cr") do |io|
top_dir.add_folder(Path["src/emails"]) do |email_dir|
email_dir.add_file("#{@email_filename}_email.cr") do |io|
ECR.embed("#{__DIR__}/templates/email.cr.ecr", io)
end
templates_dir.add_folder("#{@email_filename}_email") do |email_templates_dir|
email_templates_dir.add_file("html.ecr") do |io|
ECR.embed("#{__DIR__}/templates/html.ecr.ecr", io)
end
email_templates_dir.add_file("text.ecr") do |io|
ECR.embed("#{__DIR__}/templates/text.ecr.ecr", io)
email_dir.add_folder(Path["templates"]) do |templates_dir|
templates_dir.add_folder("#{@email_filename}_email") do |email_templates_dir|
email_templates_dir.add_file("html.ecr") do |io|
ECR.embed("#{__DIR__}/templates/html.ecr.ecr", io)
end
email_templates_dir.add_file("text.ecr") do |io|
ECR.embed("#{__DIR__}/templates/text.ecr.ecr", io)
end
end
end
end
Expand Down
Loading