What's the right way to create parameters in Soy V2? - google-closure-templates

Here is my code:
{template .someTemplate}
{#param? icon : string} /** CSS class that loads and styles the icon */
{#param? headlineHtml : any} /** Headline text with optional html for styling */
{#param? textHtml : any} /** Subtext with optional html for styling */
{#param? buttonText : string} /** The call to action text for the button */
{#param? rejectButtonText : string} /** The text for choosing to reject the call to action */
....
When I try to compile I get an error saying:
Exception in thread "main" com.google.template.soy.base.SoySyntaxException: In file ./myfile.soy:7, template com.namespace.someTemplate: Not all code is in Soy V2 syntax (found tag {#param? icon : string} not in Soy V2 syntax).`
The only info I've found online seems to suggest this is correct syntax (per Google's site here, per this cheat sheet I found), though, and Googling for "soy v2" has not given me any results that explain what is correct Soy V2 syntax.
What's the correct way to define these parameters?

It looks like this is the syntax:
{namespace test}
/**
* This is a template.
* #param name The name to say hello to
*/
{template .main}
Hello {$name}
{/template}
I also had trouble finding any documentation. I was getting the same errors saying that the {#param ...} syntax is not valid in V2. Then I found that the examples for soynode (like this one) use the comment syntax. Interestingly, it appears that this new syntax does not include a type definition at all, just a var name.

Related

Not understanding why my element.url property can t be read by require function

My goal is to display my elements URL property when i map on my array, i tryed to use 'require' according to other post on this website but for some reason it only works when i write directly the strings into my map.
i have the "images" folder into "src" folder. The file i display on bottom is in src/components thats why i used "../" but also tryed "./" just in case , still didnt work
this is my whole array i'd like to display properly:
const [products, setProducts]= useState([
{key:1 ,name:'Structure Deck Assaut d Albaz VF', price:'12,99', url:'../images/DSAlbaz.png'},
{key:2 ,name:'Grands Créateurs Booster Box VF', price:'84,91', url:'../images/grandscreateurs.png'},
{key:3 ,name:'Coffret Arsenal Mystérieux VF', price:'14,99', url:'../images/arsenalmyst.png'},
{key:4 ,name:'La Bataille du Chaos Booster Box VF', price:'84,99', url:'../images/battaillechaos.png'},
{key:5 ,name:'Fantômes du passé saison 2 VF', price:'24,99', url:'../images/fantome2nd.png'},
{key:6 ,name:'Frères de Légende Booster Box VF', price:'89,99', url:'../images/freresdelegende.png'},
{key:7 ,name:'Coffret Or Maximum VF', price:'24,99', url:'../images/OrMaximum.png'},
{key:8 ,name:'Coffret Or Maximum EN', price:'24,99', url:'../images/OrMaximum.png'},
])
this is my array maping that doesnt work as intended:
if(listToDisplay === 0){
displayList = products.map(e =>{
return<div className='product__card' key={e.key}>
<img className='product__picture' src={require(e.url)} alt='SD assaut d albaz'></img>
<h3>{e.name}</h3>
<p>{e.price}$</p>
<div className='buybutton'>Ajouter au panier</div>
</div>
})}
error code : Uncaught Error: Cannot find module '../images/grandscreateurs.png'
seems related to webpack from what i found
so i found another thread and tryed this, with import :
import Logo from '../images/grandscreateurs.png'
then tranform my object value like this :
{key:1 ,name:'Structure Deck Assaut d Albaz VF', price:'12,99', url:Logo},
error message : Uncaught Error: Cannot find module '/static/media/grandscreateurs.7cf37936cedc1da9b626.png'
i am kinda lost now since i don't know how to interact with webpack very well and don't understand how to fix it when i read the thread. thanx you for your understanding and a possible step by step solution.
If you already used the import, so don't use the require in img tag. Try this
import Logo from '../images/grandscreateurs.png'
...
<img className='product__picture' src={Logo} alt='SD assaut d albaz' />

How to make Flow and Typescript work together in React?

So, how to make Flow and Typescript work together in React? You will ask why you have both in the same project, but I am in the middle of the transition from Flow to Typescript, and for a brief period of time I would like to have them both.
The problem is, Flow reports an error for Typescript type definitions like this:
type person = {
name: string
surname: string
}
because Flow syntax is different:
type person = {
name: string,
surname: string,
}
I am using the VS Code and I can not find where (and how) to disable Flow to mark Typescript syntax as faulty and fail the compilation process. I tried everything: // #noflow, // $FlowFixMe but nothing can prevent reporting error on Typescript syntax.
Do you have any ideas?
Ok, I found the solution. In my case, I needed two lines on the top of the file:
/* eslint-disable prettier/prettier */
/* eslint-disable flowtype/no-types-missing-file-annotation */
This will do the trick.

Doxygen custom tag with a placeholder

Is it somehow possible in Doxygen to create a custom tag, which creates a documentation using a placeholder tag as its input?
What I want to accomplish is to create a custom tag for requirements. As our DOORS Urls are quite long, and diverge from SW-component to SW-component, I want to create something similar to this:
#file somefile.c
#doorsdocurl <URL to DOORS document> -> this is going to be my placeholder
...
...
...
/**
* #brief somedescription
* #req{doorsdocurl: <reqID1, reqID2,...> } -> this is going to be the second custom tag
*/
void jambo()
{
}
Is this somehow achievable with Doxygen? From what I have read, one has to put his custom tags within the ALIASES variable
In your Doxyfile you would need something like:
ALIASES = "doorsdocurl_sw_1=<URL to DOORS document>" \
"req{2}=\1 \2<br>"
and the code would look like:
/**
* #brief somedescription
*
* #req{#doorsdocurl_sw_1,reqID1}
* #req{#doorsdocurl_sw_1,reqID2}
*/
void jambo()
{
}
The \req command can of course be extended with other commands, in this respect the command xrefitem might be useful, see the manual (http://www.doxygen.nl/manual/commands.html#cmdxrefitem)

Drupal 7 Views Contextual Filters Title Override

I have a view that returns search results via the search API. It performs this use case adequately and I am happy. To crown the deliverable, I need to add a title override of the form Showing search results for '%1' which looks easy enough initially but it isn't working entirely as planned.
For a URL = mysite.com/search/all?search=wombat, where the search value is gathered from an exposed form within a block, I am either getting:
Showing search results for 'Search for "all"'
or, if I enter %1 in the title override for subject not appearing in the URL, I get:
Showing search results for %1". My goal is to get "Showing search results for 'wombat'
The title override works in that it removes the Search for ... part but the substitution picks up on "all" as the exception value (or anything else that I set as the exception value) where I need to be able to pick up the value of the query string (search=wombat).
Can anyone shed some light here?
The problem is that the '%1' and '%2' that you can use to override the title refer to your path's first and second arguments (in Drupal terms) and that would be 'search' and 'all?search=wombat' in your case...
What you need instead is the 'wombat' as a path component in itself.
Perhaps you can achieve that by working that case you're talking about: the case of a "title override for subject not appearing in the URL". There is an option in the contextual filters section (I'm assuming that's where you're working) for providing a default value when one isn't present. Perhaps you can use the 'PHP code' option there, isolate your 'wombat' string and return that as a default contextual filter, and then you can get to it via the '%1'.
The php code to get that portion of the URL should look something like this:
return htmlentities($_GET['search']);
the $_GET() returns the value of that variable in the url, and the htmlentities() is just to keep it safe, since it's using a portion of the url, which is vulnerable to XSS.
See if that combo (1) setting a default argument when one isn't present and 2) using that newly set argument in your title printout) works!
I fixed this issue.
Using following two hooks we can change the defalut value of filter Programmatically.
<?php
/**
* hook_views_pre_view
* #param type $view
* #param type $display_id
* #param type $args
*/
function MODULE_NAME_views_pre_view(&$view, &$display_id, &$args) {
if ($view->name == 'VIEW_NAME') {
$filters = $view->display_handler->get_option('filters');
$view->display_handler->override_option('filters', $filters);
}
}
/**
* hook__views_pre_build
* #param type $view
* #return type
*/
function MODULE_NAME_views_pre_build($view) {
if ($view->name=='VIEW_NAME') {
$view->display['page']->handler->handlers['filter']['filter_field']->value['value'] = 8;
return $view;
}
}
?>
This code worked for me. I am using the drupal 7.

More clarity needed on the usage assertText() function?

I have written automation test cases for my application.Below is the sample code i have used for web testing.
class UserWebTestcase extends CakeWebTestCase{
var $name='UserWebTestcase';
function testLogin001()
{
//Test if new user registration form works as intended when all the inputs are given properly.
$this->get(Configure::read('url'));
$this->setField('email', 'admin45#gmail.com');
$this->setField('tmppassword', 'admin123');
$this->setField('password_confirm', 'admin123');
$this->clickSubmit('SUBMIT');
$this->assertText('login');
}
}
In test case it always gives false even though the inputs for fields are correct.The error i got like this
(Failed
C:\xampplite\htdocs\spotchase\app\tests\cases\models\user.test.php -> UserWebTestcase -> testLogin001).
Im really confused while using the assertText() method.How should i use this assertText() method and what parameters should i pass to this method. Please help.
this is not a cakephp method, but a simpletest one.
below is the actual method
/**
* Will trigger a pass if the text is found in the plain
* text form of the page.
* #param string $text Text to look for.
* #param string $message Message to display.
* #return boolean True if pass.
* #access public
*/
function assertText($text, $message = '%s') {
return $this->assert(
new TextExpectation($text),
$this->_browser->getContentAsText(),
$message);
}
So it seems that it is just looking for the actual text within the page, not a button or other element. maybe 'welcome bob' would be a better search

Resources