@moduledoc """
Weekly schedule - extended version for admins, managers and users.
## Examples
<div class={"flex #{if @is_home, do: ~c"home"}"}> for inline conditionals (for example for class names) inside elixir templates, maybe this will be helpful to someone
"""
the compiler gives following warning:
warning: undefined module attribute @is_home, please remove access to @is_home or explicitly set it before access
lib/backend_web/live/components/week_live.ex:7
How comes the html example is considered (somehow) as code?
Is it working as designed and I’m doing something wrong??
""" is simply a plain ol’ heredoc delimiter which allows interpolation. It would be far more surprising to give """ special meaning in a core language feature. It doesn’t even have to be a heredoc, just anything that returns a string (or false or a keyword list but that is tangential to this point). This has utility as it means we can dynamically generate all or parts of it. There is a good example here.
It is, that’s what I’m saying. Heredocs allow interpolation unless you use ~S as @Nicd pointed out. I’m saying it would be weird for the core language feature of @moduledoc to treat them differently, is all.
not really… """ is a multiline string, it isn’t suppose to denote documentation neither to only be used in documentation. I guess using the term heredoc in this case is what is making your explanation confusing.
I use the terms “heredoc” and “multi-line string” interchangeably, as do parts of the Elixir documentation. The term “heredoc” has nothing to do with documentation and I certainly wasn’t trying to imply that it did by calling it that. In fact I was trying to imply the exact opposite but clearly failed.
I probably misremembered about how much I’d seen it in the docs. I only see it in a couple of places in hexdocs and elixir-lang.org has a line:
Sigils also support heredocs, that is, three double-quotes or single-quotes as separators:
In any event, I still call 'em heredocs but I guess I should stop that when talking about them 'round here though this is the first time this has happen My point was trying to convey to OP to help with their confusion was that """ isn’t special to @moduledoc or any other module attributes.