In Jekyll I'm trying to use the default filter, but allowing it to be false. In the documentation it says you can use the allow_false: true parameter. However, when I use this, the Jekyll output shows and error:
Liquid error (.../_includes/room_header.html line 7): wrong number of arguments (given 3, expected 1..2) included (Liquid::ArgumentError)
That line is:
{% assign showNameToggle = include.showNameToggle | default: true, allow_false: true %}
I tried the (almost) exact line from the documentation, but same error:
{{ include.name | default: "No Name", allow_false: true }}
Why does this happen?
Thanks!
The commit you're referring to has not been released yet.
It was committed on Oct 8, 2019.
The latest version was released on March 12, 2019.
To use unreleased code, you can point your Gemfile to the repository:
# Gemfile
# Use code from the default branch (`master`) of the GitHub repository
gem 'liquid', github: 'Shopify/liquid'
CAUTION! Use unreleased code at your own risk. It is generally unstable and may result in unexpected results.
Related
I am trying to check if a particular file with some extension exists on a centos host using salt stack.
create:
cmd.run:
- name: touch /tmp/filex
{% set output = salt['cmd.run']("ls /tmp/filex") %}
output:
cmd.run:
- name: "echo {{ output }}"
Even if the file exists, I am getting the error as below:
ls: cannot access /tmp/filex: No such file or directory
I see that you already accepted an answer for this that talks about jinja being rendered first. which is true. but i wanted to add to that you don't have to use cmd.run to check the file. there is a state that is built in to salt for this.
file.exists will check for a file or directories existence in a stateful way.
One of the things about salt is you should be looking for ways to get away from cmd.run when you can.
create:
file.managed:
- name: /tmp/filex
check_file:
file.exists:
- name: /tmp/filex
- require:
- file: create
In SaltStack Jinja is evaluated before YAML. The file creation will (cmd.run) be executed after Jinja. So your Jinja variable is empty because the file isn’t created, yet.
See https://docs.saltproject.io/en/latest/topics/jinja/index.html
Jinja statements such as your set output line are evaluated when the sls file is rendered, before any of the states in it are executed. It's not seeing the file because the file hasn't been created yet.
Moving the check to the state definition should fix it:
output:
cmd.run:
- name: ls /tmp/filex
# if your underlying intent is to ensure something runs only
# once the file exists, you can enforce that here
- require:
- cmd: create
I have a pipeline.yml defined as follows:
resources:
- name: source-code
type: hg
source:
uri: ssh://user#server/project
private_key: {{repo_private_key}}
revset_filter: tag("re:\d.\d.\d")
jobs:
- name: project
plan:
- get: source-code
trigger: true
My tasks are not listed. They are all defined under trigger above.
I set my pipeline with fly:
fly set-pipeline --target main --config pipeline.yml --load-vars-from parameters.yml --pipeline project
Now:
1) Committing a new revision with a tag matching \d.\d.\d (say, 1.1.1) and pushing it to ssh://user#server/project does not to trigger a new build. How long should I wait? Does Concourse pull remote info every x number of minutes? Should revset_filter result in all applicable revisions? I tried changing it to last(tag("re:\d.\d.\d")) with same results.
2) Triggering a job manually, through the web GUI or fly, pulls a non-matching ref. For example, here's the latest "matching" source code output:
author My Name <name#company.com>
author_date 2017-07-24 13:27:40 -0500
commit 0ba59f2ee956f6317fc257086026fac4e7c0d8de
message Added tag 1.8.8 for changeset 1392e7143f45
tags tip
This does not match tag("re:\d.\d.\d") - i.e., the last line should read tags 1.8.8.
Lastly, I tried using tag_filter with same results.
It seems to me that revset_filter and tag_filter are not being applied.
Using: composer search 'tokens'command the IDE threw this error. I can't search neither download packages from: packagist.org
C:\ProgramData\ComposerSetup\bin\composer.bat search fosuserbundle
[Seld\JsonLint\ParsingException]
"http://packagist.org/packages.json" does not contain valid JSON
Parse error on line 1:
<HTML><HEAD><meta h
^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
search [-N|--only-name] tokens1 ... [tokensN]
In windows machine, I've followed all these steps and get back in a correct behaviour (my problem was happening with composer require, but I believe it's the same as you described using composer search or if we would be using composer install for example. So, let´s see the steps:
Update composer (`composer self-update)
Disable IPV6 (as pointed in official docs, misconfigured IPV6 setting is a common source of issues)
Delete (or rename to repo_temp) your folder %LOCALAPPDATA%\Composer\repo (in order to have all contents updated)
Delete (or rename to vendor_temp) your vendor folder inside your project (in order to force composer to download all components again, and as pointed in this thread comment)
After doing these steps, in my, case, the issue was gone!
Message before (ERROR):
> composer require ...
...
"https://packagist.org/packages.json" does not contain valid JSON
Parse error on line 1:
▼\\\\\\♥��ݎ♀���
^
Expected one of: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Message after doing the steps (OK)!:
> composer require ...
...
Writing lock file
Generating autoload files
I've got Sublime Text 2 (+ the pylinter package) and pylint installed, but can't get the pylint_path setting to work; my Pylinter.sublime-settings file looks like:
{
"verbose":true,
"message_stay": true,
"pylint_path": "Z:\\python\\pylintrc"
}
but when I run pylint I get the following output:
- PyLinter: Verbose is True
- PyLinter: Running Pylinter on Z:\TestProject\test.py
- PyLinter: Current PYTHONPATH is ''
- PyLinter: Updated PYTHONPATH is ''
- PyLinter: Running command with Pylint (1, 4, 1)
- PyLinter: python Z:\python\pylintrc --reports=n --msg-template={path}:{line}:{msg_id}:{msg} --disable=C0303 Z:\TestProject\test.py
error: Fatal pylint error:
SyntaxError: invalid syntax
- PyLinter: No errors found
but I've put errors in to prove to myself it works (or doesn't..)! If I remove the pylint_path setting, it works and the errors do get reported. (For completion, I've tried Z:/TestProject/test.py and Z:\TestProject\test.py too, and get the same result each time)
This was asked a long time ago, but I just stumbled across it from google.
You want to set pylint_rc instead of pylint_path.
From the default settings:
// Full path to the lint.py module in the pylint package
"pylint_path": null,
// Optional full path to a Pylint configuration file
"pylint_rc": null,
Ruby on Rails sometimes gives you annoying "Ignoring attempts to close x with y" warnings arising from assert_select. Often these warnings are the result of invalid HTML, but sometimes they appear even if the HTML is valid. The error in my case looks like this while running ruby test/functional/my_controller_test.rb :
..ignoring attempt to close div with h2
opened at byte 8551, line 207
closed at byte 9554, line 243
attributes at open: {"class"=>"my_css_class", "id"=>"object_1"}
text around open: " \r\n \r\n \r\n \r\n\r\n <div class=\"my_css_class"
text around close: "</a>\r\n </h2>\r\n\r\n <span"
But there is no attempt to close a div with a h2 tag. I tried a HTML validator, but without success. The -W0 parameter mentioned by Giles seems to help - ruby -W0 test/functional/my_controller_test.rb gives no longer a warning, but this does not work for rake test:whatever. What does -W0 do, and how can you avoid using it?
In test helper:
class ActionController::TestCase
include Devise::TestHelpers
Paperclip.options[:log] = false
Mocha::Deprecation.mode = :disabled
#
# kill verbsity
#
verbosity = $-v
$-v = nil
end
There are various command line options for Ruby unit tests. -W does not belong to them, it is a command line option for pure Ruby. As ruby --help says, the ruby -W[level] command line option sets the warning level for Ruby; 0=silence, 1=medium, 2=verbose (default). ruby -W0 sets the warning level to silence.
$ ruby --help
[...]
-w turn warnings on for your script
-W[level] set warning level; 0=silence, 1=medium, 2=verbose (default)
The -W flag also activates the "verbose" mode of Ruby. Mislav has a good explanation of the verbose mode. From within Ruby code, verbosity can be set and tested with the value of the $VERBOSE global variable, which can have 3 states: nil ("0"), false ("1"), and true ("2"). So you can suppress warning for your Test::Unit test by setting
$VERBOSE = nil
in your test_helper.rb. For running RSpecs test you can suppress ruby warning similarly.