heterocephalus
heterocephalus copied to clipboard
Feature request: comment syntax
Sometimes we need to explain the intention of a templating code. Comments can be useful for such situations. Though I have no idea how the comment syntax should look like.
Thanks for an issue.
Heterocephalus
is supposed to be used with another template engine.
So, we can use comment syntax of the other template engine.
For example, if we are using pug
, we can inject any comment as follows.
.someBlock
| %{forall paragraph <- lines paragraphs}
p.someBlock_paragraph
// This is comment syntax for pug
| \#{ paragraph }
| %{endforall}
Even with a raw HTML, we can use comment like bellow example.
<div class="someBlock">
%{forall paragraph <- lines paragraphs}
<p class="someBlock_paragraph">
<!-- This is comment syntax for html -->
\#{ paragraph }
</p>
%{endforall}
</div>
Is this work for your intention?
Yeah, I indeed am using that workaround. The result code contains the comments and I thought it may deliver false intentions or things that I don't want to expose to who can read the result code. On Sun, Mar 11, 2018 at 0:23 Kadzuya OKAMOTO [email protected] wrote:
Thanks for an issue.
Heterocephalus is supposed to be used with another template engine. So, we can use comment syntax of the other template engine.
For example, if we are using pug, we can inject any comment as follows.
.someBlock | %{forall paragraph <- lines paragraphs} p.someBlock_paragraph // This is comment syntax for pug | #{ paragraph } | %{endforall}
Even with a raw HTML, we can use comment like bellow example.
%{forall paragraph \#{ paragraph } %{endforall}Is this works for your intention?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arowM/heterocephalus/issues/21#issuecomment-372037891, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAwj2Pv3VD1d24KxifiAnN_zSf_X4fmks5tc_AEgaJpZM4Sk2_u .
Note, for comparison, Hamlet supports one-line comments prefixed with $#
.
I'm not sure it's documented, and I might have sigils in reverse order, but
there are definitely Hamlet-level comments. :)
On Mar 10, 2018 11:02, "Hong Minhee" [email protected] wrote:
Yeah, I indeed am using that workaround. The result code contains the comments and I thought it may deliver false intentions or things that I don't want to expose to who can read the result code. On Sun, Mar 11, 2018 at 0:23 Kadzuya OKAMOTO [email protected] wrote:
Thanks for an issue.
Heterocephalus is supposed to be used with another template engine. So, we can use comment syntax of the other template engine.
For example, if we are using pug, we can inject any comment as follows.
.someBlock | %{forall paragraph <- lines paragraphs} p.someBlock_paragraph // This is comment syntax for pug | #{ paragraph } | %{endforall}
Even with a raw HTML, we can use comment like bellow example.
%{forall paragraph \#{ paragraph } %{endforall}Is this works for your intention?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/arowM/heterocephalus/issues/21# issuecomment-372037891>, or mute the thread <https://github.com/notifications/unsubscribe- auth/AAAwj2Pv3VD1d24KxifiAnN_zSf_X4fmks5tc_AEgaJpZM4Sk2_u> .
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/arowM/heterocephalus/issues/21#issuecomment-372040705, or mute the thread https://github.com/notifications/unsubscribe-auth/AAg3qsdb6J4ux-hS6j8sC0ENy-8aTDCpks5tc_kOgaJpZM4Sk2_u .
@dahlia Thanks. It makes sense! Then how about this work around?
<div class="someBlock">
%{forall paragraph <- lines paragraphs}
<p class="someBlock_paragraph">
\#{ comment "This is a comment." }
\#{ paragraph }
</p>
%{endforall}
</div>
comment :: String -> String
comment = const ""
@chreekat Thanks for helpful information.
I do not want to introduce new syntaxes by the reason of just convenience because it is easy to add new feature but it is difficult to remove it after released it. To tell the truth, I don't know it's worth valuable to introduce comment syntax. Would you be able to lend your expertise?
This point would be best made with concrete examples. @dahlia, do you have any to share? I will look to see if I have any, also.
Is there any opinions, @dahlia ?
Actually I use Heterocephalus for generating Python and JavaScript codes. As they both have their own comments, I currently stick with a workround mentioned above. The problem is that its content is out of scope and merely nonsense for people who read the generated codes.
Thanks.
What do you think about this idea using comment
function?
Although using a no-op function barely works, since its syntax is quite picky (e.g., need to escape a double quote), I personally am not likely to use that.
OK. It makes sense. The other reason, I think, to introduce special notation is to improve readability.
@dahlia , are you interested in taking a stab at a PR?
I meant if you are not interested in creating PR by yourself, I'll do it by myself. I'll assume this issue is not actually important for you if there are no replies from you in a week from today, @dahlia .
Sorry for the late response. I would appreciate if you're going to add the own comment syntax to Heterocephalus. 😄
Thanks for response! I'll do it.