how do I get the base_url in stencil - bigcommerce

I'm unable to get the base_url within a stencil template. {{ settings.base_url }} always returns an empty string. https://stencil.bigcommerce.com/docs/settings-object.
Is there another global stencil object that contains the site url?

The function in (pencil-response.js)[https://github.com/bigcommerce/stencil-cli/blob/master/server/plugins/renderer/responses/pencil-response.js#L79-L85]
intentionally destroys those values using a regex.
regex = new RegExp(internals.escapeRegex(context.settings.base_url), 'g');
content = content.replace(regex, '');
this commit used a value of request.info.host:
https://github.com/bigcommerce/stencil-cli/commit/fb9611502613f00a364a8d9ea4e1d3351c834d08
I sumitted a fix in this pull request. https://github.com/bigcommerce/stencil-cli/pull/396

Related

Add target blank to a link in a props in Vue.js

I use the ReadMore plugin to crop articles in a page. The plugin provides a props to redirect to a http link when the "read more" is clicked. But I need to display the link in a new tab. The props receives the link in a string.
I tried several ways to add the target blank attribute to this string before passing it to the props. With no success. Like:
http://www.example.com/page-to-see.html target=_"blank"
I used it with or without quotes but in any case, the link works but the attribute is skipped.
Is there a way to intercept this and add a target blank later?
I saw in other questions the use of router-link but I don't know how to manipulate the props content in the first place.
Any clue would be warmly welcomed
Edit: adding more code to give a clearer explanation of the problem I try to solve:
In the template:
<read-more more-str="read more" :text="dwId.texte" :link="dwId.link" less-str="less" :max-chars="540"></read-more>
I get the values from a DB with Axios. The props are specified by the plugin documentation.
The :link must be a string and it's what it gets from the DB. It works. But as I explained, I need to open in a new tab.
Edit: what I tried:
I try to make a computed property that would add the target blank to a string and use it in the read-more props:
computed: {
target: function() {
return this.dwIds.filter((dwId) => {
return dwId.link + target="_blank"
});
},
}
I have two issues here: first , the result is an object and the props requires a string. Furthermore, the way I add the target blank is not correct but I can't find the right syntax yet.
You need to use it as a directive, and override parts of the initial element you're passing. Otherwise there is no way to "intercept" it. Here's the code to the "component" version that won't do the trick for you.

How to send new line character in url?

I'm using Vuejs for frontend and I have blade template displayed using iframe. I want to send data into blade such that Whatever i type inside text field it should be displayed on the laravel blade template.
<iframe :src="template" #load="onTemplateLoad()"></iframe>
and template is defined as
this.template = '/templates/email_templates/' + t.id + '?footer_message=' + this.footer_message;
If there is any new line character in footer_message it should be displayed. Now it is ignoring the new line. Is there any way to solve it.
Anyway friends I got it, before appending the value just replace all new line character with '%0A'.
In my code I added this message.replace(/\n/g, '%0A');. Which Works fine.

Jade render's my html twice

Maybe I'm asking my question wrong since it seems like the answer should be relatively easy to search for. I am parsing some .md files in express and returning the response to a jade template.
= body returns <h1>my content</h1> as a string.
#{body} returns <<h1>my content</h1>><!--<h1-->my content> or effectively:
<
my content #as a styled h1
>my content>
Thanks for any help.
UPDATE FOR CLARITY:
My question is - why is the content returning twice.
why is the content returning twice.
Because with the syntax of #{VARIABLE} Jade replace the variable with the value and interpret it as a HTML tag. For example:
passing a local variable {foo: 'bar'} and this template
#{foo}
generat this HTML
<bar></bar>
So you should pass the content and don't let interpret it by jade using = or != for unbuffered code:
!=body
btw: a whitespace is forbidden between = and the variable!

Yii: Is is possible to link a specified CJuiTabs from external page?

I've a page with a CjuiTab, with seven tabs.
I need a link into from external page or from the same page, to REFRESH the page directly a the specified tab.
I need to use ChtmlLink, but how to append '#' to end of url ?
CHtml::link (Yii::t('general','Annulla'),
array("company/update",
'id'=> $companyId)
where / how to append '#contactTab' !?
You just need to pass a '#'=>'value'. The value of the url parameter for CHtml::link is ultimately passed to CController::createUrl, and the doc states:
additional GET parameters (name=>value). Both the name and value will be URL-encoded. If the name is '#', the corresponding value will be treated as an anchor and will be appended at the end of the URL.
So try with:
CHtml::link (Yii::t('general','Annulla'),
array(
"company/update",
'id'=> $companyId,
'#'=>'contactTab'
)
);
Update: For same page links you'll need to use some javascript to reload the page after the browser url is set:
CHtml::link (Yii::t('general','Annulla'),
array(
"company/update",
'id'=> $companyId,
'#'=>'contactTab'
),
array('onclick'=>'setTimeout("location.reload(true);",100);')
);
(Not sure if this is the best way to reload though)

VB.NET hates </script> tag in string literal

I am trying to update some of my projects old login code, which is a bunch of aspx files with inline VB.NET (no codebehind).
The page in question uses a master page layout. I am trying to expose the header of this master page to the slave pages, which I did by adding a placeholder in the header and exposing it as a property of the master page.
The problem comes in when I try to add a script tag to the header, like this:
Master.Header.Controls.Add(New LiteralControl("<script type='text/javascript' src='http://mysite.com/myscript.ashx'></script>"))
Then i get the error "Only Content controls are allowed directly in a content page that contains Content controls."
I think the aspx parser is seeing the </script> in the string literal and thinking that it is then end of the tag, and giving me that error because it thinks the content following that end tag are not in an block. I can add other tags to the header perfectly fine.
What do you think?
You can escape the / in </script> to prevent this.
Master.Header.Controls.Add(New LiteralControl("<script type='text/javascript' src='http://mysite.com/myscript.ashx'><\/script>"))
Alternatively, you can try
Dim gc As New HtmlGenericControl
gc.TagNane = "script"
gc.Attributes.Add("type", "javascript")
gc.Attributes.Add("src", "http://mysite.com/myscript.ashx")
Master.Header.Controls.Add(gc)