Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
mshivashankar committed Apr 25, 2024
1 parent ec8ebb6 commit 197b640
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions asabiris/orchestration/sendemail.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ async def send_email(


async def _render_template(self, template: str, params: Dict, body_template_wrapper=None) -> Tuple[str, str]:
# First, determine if a default wrapper needs to be used
if body_template_wrapper in [None, '']:
body_template_wrapper = self.MarkdownWrapper

# Check the template paths right after updating body_template_wrapper
if not template.startswith('/Templates/Email/'):
raise ASABIrisError(
ErrorCode.INVALID_PATH,
Expand All @@ -119,6 +124,7 @@ async def _render_template(self, template: str, params: Dict, body_template_wrap
}
)

# Proceed with rendering the template
jinja_output = await self.JinjaService.format(template, params)

ext = os.path.splitext(template)[1]
Expand All @@ -129,15 +135,10 @@ async def _render_template(self, template: str, params: Dict, body_template_wrap
body, subject = find_subject_in_md(jinja_output)
html_body = self.MarkdownToHTMLService.format(body)

# Determine the appropriate wrapper to use.
# First preference is given to body_template_wrapper if it's provided and not empty.
# If body_template_wrapper is None or empty, fallback to the class's MarkdownWrapper.
wrapper_to_use = body_template_wrapper if body_template_wrapper not in [None, ''] else self.MarkdownWrapper

# Apply the wrapper if it exists and is not empty
if wrapper_to_use not in [None, '']:
if body_template_wrapper not in [None, '']:
html_body_param = {"content": html_body}
html_body = await self.JinjaService.format(wrapper_to_use, html_body_param)
html_body = await self.JinjaService.format(body_template_wrapper, html_body_param)
else:
html_body = convert_markdown_to_full_html(html_body)

Expand Down

0 comments on commit 197b640

Please sign in to comment.